Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix modification of input on *_any/*_all predications

  • Loading branch information...
commit f9271fd6a27006b1c544b27313038a47a01facce 1 parent deae21c
@ernie ernie authored tenderlove committed
Showing with 18 additions and 0 deletions.
  1. +2 −0  lib/arel/predications.rb
  2. +16 −0 test/attributes/test_attribute.rb
View
2  lib/arel/predications.rb
@@ -163,6 +163,7 @@ def desc
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 @@ def grouping_any method_id, others
end
def grouping_all method_id, others
+ others = others.dup
first = send method_id, others.shift
Nodes::Grouping.new others.inject(first) { |memo,expr|
View
16 test/attributes/test_attribute.rb
@@ -366,6 +366,14 @@ module Attributes
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 Attributes
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
Please sign in to comment.
Something went wrong with that request. Please try again.