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:
parent
f3fce59d13
commit
e8cdb3d5e7
2 changed files with 7 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue