File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
lib/active_record/relation Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ def joins(*args)
47
47
clone . tap { |r | r . joins_values += args if args . present? }
48
48
end
49
49
50
- def where ( opts , other = nil )
51
- value = build_where ( opts , other )
50
+ def where ( opts , * rest )
51
+ value = build_where ( opts , rest )
52
52
value ? clone . tap { |r | r . where_values += Array . wrap ( value ) } : clone
53
53
end
54
54
@@ -160,10 +160,10 @@ def build_arel
160
160
arel
161
161
end
162
162
163
- def build_where ( opts , other = nil )
163
+ def build_where ( opts , other = [ ] )
164
164
case opts
165
165
when String , Array
166
- @klass . send ( :sanitize_sql , other ? [ opts , other ] : opts )
166
+ @klass . send ( :sanitize_sql , other . empty? ? opts : ( [ opts ] + other ) )
167
167
when Hash
168
168
attributes = @klass . send ( :expand_hash_conditions_for_aggregates , opts )
169
169
PredicateBuilder . new ( table . engine ) . build_from_hash ( attributes , table )
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ def test_apply_relation_as_where_id
22
22
assert_equal 5 , Post . where ( :id => post_authors ) . size
23
23
end
24
24
25
+ def test_multivalue_where
26
+ posts = Post . where ( 'author_id = ? AND id = ?' , 1 , 1 )
27
+ assert_equal 1 , posts . to_a . size
28
+ end
29
+
25
30
def test_scoped
26
31
topics = Topic . scoped
27
32
assert_kind_of ActiveRecord ::Relation , topics
You can’t perform that action at this time.
0 commit comments