mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
avoid creating a set if no where values are removed
This commit is contained in:
parent
50823452f7
commit
f3ebbeae6e
2 changed files with 14 additions and 0 deletions
|
@ -131,6 +131,8 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def filter_binds(lhs_binds, removed_wheres)
|
||||
return lhs_binds if removed_wheres.empty?
|
||||
|
||||
set = Set.new removed_wheres.map { |x| x.left.name }
|
||||
lhs_binds.dup.delete_if { |col,_| set.include? col.name }
|
||||
end
|
||||
|
|
|
@ -1556,4 +1556,16 @@ class RelationTest < ActiveRecord::TestCase
|
|||
merged = left.merge(right)
|
||||
assert_equal [], merged.bind_values
|
||||
end
|
||||
|
||||
def test_merging_keeps_lhs_bind_parameters
|
||||
column = Post.columns_hash['id']
|
||||
binds = [[column, 20]]
|
||||
|
||||
right = Post.where(id: Arel::Nodes::BindParam.new('?'))
|
||||
right.bind_values += binds
|
||||
left = Post.where(id: 10)
|
||||
|
||||
merged = left.merge(right)
|
||||
assert_equal binds, merged.bind_values
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue