allow merging a single where value

This commit is contained in:
Jon Leighton 2012-04-22 09:49:56 +02:00
parent f3fce59d13
commit e8cdb3d5e7
2 changed files with 7 additions and 1 deletions

@ -85,7 +85,7 @@ def merged_binds
def merged_wheres
if values[:where]
merged_wheres = relation.where_values + values[:where]
merged_wheres = relation.where_values + Array(values[:where])
unless relation.where_values.empty?
# Remove duplicates, last one wins.

@ -156,6 +156,12 @@ def test_references_values_dont_duplicate
relation = Relation.new(:a, :b, where: [:foo])
assert_equal [:foo], relation.where_values
end
test 'merging a single where value' do
relation = Relation.new(:a, :b)
relation.merge!(where: :foo)
assert_equal [:foo], relation.where_values
end
end
class RelationMutationTest < ActiveSupport::TestCase