Fix eager load with Arel joins to maintain the original joins order#39305
Merged
kamipo merged 1 commit intorails:masterfrom May 16, 2020
Merged
Fix eager load with Arel joins to maintain the original joins order#39305kamipo merged 1 commit intorails:masterfrom
kamipo merged 1 commit intorails:masterfrom
Conversation
rails#38354 is caused by rails#36304, to fix invalid joins order for through associations. Actually passing Arel joins to `joins` is not officially supported unlike string joins, and also Arel joins could be easily converted to string joins by `to_sql`. But I'd not intend to break existing apps without deprecation cycle, so I've changed to mark only implicit joins as leading joins, to maintain the original joins order for user supplied Arel joins. Fixes rails#38354.
kamipo
added a commit
that referenced
this pull request
May 16, 2020
Fix eager load with Arel joins to maintain the original joins order
|
This change seems to cause some combination of scope merge to generate invalid SQL because the joins ordering is now invalid. I get a When I compare before / after this commit, looks like the only change is one of the join is now the very first join (which doesn't work) and before it was in a "correct" order. I have a chain of two table joined like library -> book -> author and the author join is placed before the book join. |
Member
Author
|
Can you create a new issue with reproducible script https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_migrations_master.rb? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#38354 is caused by #36304, to fix invalid joins order for through
associations.
Actually passing Arel joins to
joinsis not officially supportedunlike string joins, and also Arel joins could be easily converted to
string joins by
to_sql. But I'd not intend to break existing appswithout deprecation cycle, so I've changed to mark only implicit joins
as leading joins, to maintain the original joins order for user supplied
Arel joins.
Fixes #38354.