1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

View file

@ -85,7 +85,7 @@ module ActiveRecord
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.

View file

@ -156,6 +156,12 @@ module ActiveRecord
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