mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix alias confliction when joining same table on has many through with left_joins
This regression was caused by #30995 due to `Hash#fetch` won't invoke
default proc. Just revert the change since #30995 is completely fixed by
e9c1653
.
Fixes #33048.
This commit is contained in:
parent
fcfe29cd26
commit
a81d47aa41
2 changed files with 5 additions and 1 deletions
|
@ -33,7 +33,7 @@ module ActiveRecord
|
|||
elsif join.is_a?(Arel::Nodes::Join)
|
||||
join.left.name == name ? 1 : 0
|
||||
elsif join.is_a?(Hash)
|
||||
join.fetch(name, 0)
|
||||
join[name]
|
||||
else
|
||||
raise ArgumentError, "joins list should be initialized by list of Arel::Nodes::Join"
|
||||
end
|
||||
|
|
|
@ -1289,6 +1289,10 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
|
|||
assert_equal authors(:david), Author.joins(:comments_for_first_author).take
|
||||
end
|
||||
|
||||
def test_has_many_through_with_left_joined_same_table_with_through_table
|
||||
assert_equal [comments(:eager_other_comment1)], authors(:mary).comments.left_joins(:post)
|
||||
end
|
||||
|
||||
def test_has_many_through_with_unscope_should_affect_to_through_scope
|
||||
assert_equal [comments(:eager_other_comment1)], authors(:mary).unordered_comments
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue