GithubHelp home page GithubHelp logo

Left and Right join about pypika HOT 10 CLOSED

kayak avatar kayak commented on August 22, 2024
Left and Right join

from pypika.

Comments (10)

twheys avatar twheys commented on August 22, 2024 2
Query
  .from_(table)
  .join(table2, JoinType.left)
  .on(...)

vs .

Query
  .from_(table)
  .left_join(table2)
  .on(...)

I don't really see how the code is any more complicated from API perspective, but definitely not opposed to having some extra join functions that call join passing in the JoinType enum. Feel free to raise a PR, i'll have a look right away.

from pypika.

twheys avatar twheys commented on August 22, 2024 1

Yes, when chaining the join function, there is a kwarg called how which takes a pypika.JoinType value

from pypika.

twheys avatar twheys commented on August 22, 2024 1

#348
While writing the docs, I figured it wouldn't take more thn a couple of minutes to add these functions. Mind taking a look at seeing if it meets your expectations?

from pypika.

dabaus avatar dabaus commented on August 22, 2024

OMG why not just make an innerJoin function and leftJoin function?
Then you have covered 95% of all usecases for joins.

from pypika.

twheys avatar twheys commented on August 22, 2024

Because we have real use cases for right and outer joins as well. A single function with a join type argument resulted in less code which was easier to maintain.

from pypika.

dabaus avatar dabaus commented on August 22, 2024

But it creates more complicated code for people using the framework.
I mean, the purpose of this framework was to make it easier for people to write queries instead of using strings. But in this case, this framework results in more complicated code than SQL, so it defeats it's own purpose.

from pypika.

airtonzanon avatar airtonzanon commented on August 22, 2024

It would be nice to have the functions innerJoin and leftJoin (maybe also for rightJoin).
What do you think to create these functions using the join that PyPika already have?
It would be a small improvement and, maybe will leave the code clearer.

from pypika.

dabaus avatar dabaus commented on August 22, 2024

@airtonzanon Yes it would be nice to have a "syntax sugar" for the most common join types.
I spent some time googling the docs, and then eventually i found out how to make a left join from searching the code on github. It could be easier.

from pypika.

twheys avatar twheys commented on August 22, 2024

@dabaus I will look at improving the docs so ensure that the join types are clearly covered.

from pypika.

airtonzanon avatar airtonzanon commented on August 22, 2024

Nice thing @twheys .

@dabaus Do you want to implement it? I can help if you want, or create the PR. It's your call.

Also, I think, with this PR, we could improve the Documentation of this place. If we try to improve the docs bit a bit, we'll have everything updated.

from pypika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.