forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix order of LEFT JOINS when using
eager_load
:
- Fix rails#54181 - When multiple stashed joins (eager load, left joins) were added, the join produced by eager loading always had the least precedence. This could result in producing invalid query in the following case: ```ruby Post.eager_load(:comments).merge(Comment.left_joins(:user)).count # SELECT COUNT(DISTINCT "posts"."id") FROM "posts" LEFT OUTER JOIN "users" ON "users"."id" = "comments"."user_id" LEFT OUTER JOIN "comments" ON "comments"."post_id" = "posts"."id" WHERE "users"."id" IS NULL ``` Now the order of LEFT JOIN produced by eager load will be respected.
- Loading branch information
1 parent
fa6886b
commit 6822554
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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