mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix modification of input on *_any/*_all predications
This commit is contained in:
parent
3cd905ee7b
commit
3d21dabaa6
2 changed files with 18 additions and 0 deletions
|
@ -163,6 +163,7 @@ module Arel
|
|||
private
|
||||
|
||||
def grouping_any method_id, others
|
||||
others = others.dup
|
||||
first = send method_id, others.shift
|
||||
|
||||
Nodes::Grouping.new others.inject(first) { |memo,expr|
|
||||
|
@ -171,6 +172,7 @@ module Arel
|
|||
end
|
||||
|
||||
def grouping_all method_id, others
|
||||
others = others.dup
|
||||
first = send method_id, others.shift
|
||||
|
||||
Nodes::Grouping.new others.inject(first) { |memo,expr|
|
||||
|
|
|
@ -366,6 +366,14 @@ module Arel
|
|||
SELECT "users"."id" FROM "users" WHERE ("users"."id" = 1 OR "users"."id" = 2)
|
||||
}
|
||||
end
|
||||
|
||||
it 'should not eat input' do
|
||||
relation = Table.new(:users)
|
||||
mgr = relation.project relation[:id]
|
||||
values = [1,2]
|
||||
mgr.where relation[:id].eq_any(values)
|
||||
values.must_equal [1,2]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#eq_all' do
|
||||
|
@ -382,6 +390,14 @@ module Arel
|
|||
SELECT "users"."id" FROM "users" WHERE ("users"."id" = 1 AND "users"."id" = 2)
|
||||
}
|
||||
end
|
||||
|
||||
it 'should not eat input' do
|
||||
relation = Table.new(:users)
|
||||
mgr = relation.project relation[:id]
|
||||
values = [1,2]
|
||||
mgr.where relation[:id].eq_all(values)
|
||||
values.must_equal [1,2]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#matches' do
|
||||
|
|
Loading…
Reference in a new issue