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
Merge with joins adds secondary joins to wrong part of query #32363
Comments
Can you create an executable test script using one of the templates here, that would demonstrate the problem you are seeing? |
I've also been seeing the same issue with symbol joins. During the weekend I will make a test script. |
Replicating the problem with symbol joins in a test script proved more difficult than expected. I currently have a scope which works as intended in rails console and in a test script but fails when called with the same arguments from a controller. |
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
Thanks for working on this @quickdudley! |
For those who has the same problem there is a workaround: Instead of
do this:
|
Steps to reproduce
I have a query along these lines:
If
p_scope
contains no joins: the query works as expected. Ifp_scope
contains joins: the full query is constructed incorrectly.Expected behavior
In the event that
p_scope
contains joins: the generated SQL should be along the line of:Actual behavior
The generated SQL is along the lines of:
This is a problem because SQL join syntax is left-associative: the join clauses from
p_scope
refer to columns which are outside of their namespace.System configuration
Rails version:
Rails 5.0.0.1
Ruby version:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17]
The text was updated successfully, but these errors were encountered: