Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't change $or query values to $in hash

  • Loading branch information...
commit 35699ac8ce2bc8fec28743f44e2961ad860d833f 1 parent ed8331c
@rlivsey rlivsey authored jnunemaker committed
View
2  lib/plucky/criteria_hash.rb
@@ -120,7 +120,7 @@ def normalized_value(parent_key, key, value)
case value
when Array, Set
value.map! { |v| Plucky.to_object_id(v) } if object_id?(parent_key)
- parent_key == key ? {'$in' => value.to_a} : value.to_a
+ parent_key == key && key != :$or ? {'$in' => value.to_a} : value.to_a
when Time
value.utc
when String
View
4 test/plucky/test_criteria_hash.rb
@@ -150,6 +150,10 @@ class CriteriaHashTest < Test::Unit::TestCase
CriteriaHash.new(:numbers => {'$all' => [1,2,3]})[:numbers].should == {'$all' => [1,2,3]}
CriteriaHash.new(:numbers => {'$any' => [1,2,3]})[:numbers].should == {'$any' => [1,2,3]}
end
+
+ should "not turn value to $in with $or key" do
+ CriteriaHash.new(:$or => [{:numbers => 1}, {:numbers => 2}] )[:$or].should == [{:numbers=>1}, {:numbers=>2}]
+ end
end
context "with set value" do
Please sign in to comment.
Something went wrong with that request. Please try again.