diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-26 20:03:03 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-27 21:43:57 +0900 |
commit | 20ede2e2e6e28cf26da4d056cd7638b27d48ed57 (patch) | |
tree | 0c8d93b49aa2d2d015f34279316e5bfa7dcb2985 /activerecord/test/models | |
parent | bbc3704bb38d9739d46d94d12a2a854f47b52cbe (diff) | |
download | rails-20ede2e2e6e28cf26da4d056cd7638b27d48ed57.tar.gz rails-20ede2e2e6e28cf26da4d056cd7638b27d48ed57.tar.bz2 rails-20ede2e2e6e28cf26da4d056cd7638b27d48ed57.zip |
Fix merging left_joins to maintain its own `join_type` context
This fixes a regression for #35864.
Usually, stashed joins (mainly eager loading) are performed as LEFT
JOINs.
But the case of merging joins/left_joins of different class, that
(stashed) joins are performed as the same `join_type` as the parent
context for now.
Since #35864, both (joins/left_joins) stashed joins might be contained
in `joins_values`, so each stashed joins should maintain its own
`join_type` context.
Fixes #36103.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/post.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 090b576a5d..50c0dddcf2 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -43,6 +43,7 @@ class Post < ActiveRecord::Base has_one :first_comment, -> { order("id ASC") }, class_name: "Comment" has_one :last_comment, -> { order("id desc") }, class_name: "Comment" + scope :no_comments, -> { left_joins(:comments).where(comments: { id: nil }) } scope :with_special_comments, -> { joins(:comments).where(comments: { type: "SpecialComment" }) } scope :with_very_special_comments, -> { joins(:comments).where(comments: { type: "VerySpecialComment" }) } scope :with_post, ->(post_id) { joins(:comments).where(comments: { post_id: post_id }) } |