-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support LATERAL joins #1425
Comments
If you would like to send a PR, it would be appreciated. :) |
I dived in and took a look, but I don't think I'm capable of implementing this. I've only been using Elixir for a few months. :) |
@ashleyw no problem, we will tackle this after 2.0 is out, unless someone decides to handle it first. :) |
I started having a look into this yesterday and I came up with two ways to do it:
Obviously it's a classic trade off:
Let me know if you want me to push through with one of these and maybe I can ask questions if I get stuck! Thanks! EDIT: 3) Looking at the definition of LATERAL it seems to only apply to subqueries so maybe the simplest way would be to change the params of a subquery( , lateral: true) which would be even simpler and not touch any of the join code. I think that is the one! |
Totally out of my depth here.. but am I right in thinking |
@ashleyw that would be very tricky to implement indeed. Subqueries today cannot interact with elements outside of the query. Although you can use fragments when writing your lateral joins (and that should work fine). |
Forgot to reference this issue in the PR. |
Is there any workaround to use Why I can't use binding
|
http://www.postgresql.org/docs/9.3/static/queries-table-expressions.html#QUERIES-LATERAL
http://blog.heapanalytics.com/postgresqls-powerful-new-join-type-lateral/
It would be immensely valuable when combined with
subquery
, for instance getting the most recent comments on a post:It doesn't appear that using
INNER JOIN LATERAL
is possible even with afragment
, sincejoin
wraps the fragment in additional parentheses (i.e.INNER JOIN (LATERAL (SELECT …))
), which isn't valid AFAIK.The text was updated successfully, but these errors were encountered: