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
ActiveRecord left joins out of order #32598
Comments
https://stackoverflow.com/questions/9614922/does-the-join-order-matter-in-sql "Outer joins are not associative" |
I am not sure what you are trying to communicate. I read the post and it says outer joins order does matter. |
Read post carefully, order of params does matter (tables, columns), not joins itself. |
Could you explain better the expected behavior and the actual behavior? "should keep order" doesn't tell anything to me. Order of what? |
I think it is related to #15461 |
YEA that is exactly it! I'll gladly pick up the stale PR! I just didn't even know where to start. |
Here is our example that raises the scope :expired, ->(service, time = 1.month) {
distinct.
left_joins(:timestamps).
joins("LEFT JOIN timestamp_kinds...")
} |
This might take a while to fix. Right now joins bucketed together.
String joins may or may not have a left join contained in them so they may need to keep order with outer joins. |
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
This is still an issue
returns error. |
+1 for PR |
I'm willing to create a PR for this. I ran into this issue earlier today. |
Did this bug be fixed? I ran into this issue, too. (Rails 5.2.4) |
Fixed by #35864 in Rails 6.0. |
Steps to reproduce
Combine sql left join with a arel join causes wrong order
https://gist.github.com/ryan-plated/cae50e8eceb621f8a76d41f2e6d1b5ec
Expected behavior
should keep order
Actual behavior
goes out of order
System configuration
Rails version: master
Ruby version: 2.5.0
The text was updated successfully, but these errors were encountered: