Permalink
Browse files

allow merging a single where value

  • Loading branch information...
1 parent f3fce59 commit e8cdb3d5e73c1be3d551f55602de7f5c34d43c42 @jonleighton jonleighton committed Apr 22, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation/merger.rb
  2. +6 −0 activerecord/test/cases/relation_test.rb
@@ -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

0 comments on commit e8cdb3d

Please sign in to comment.