mongoid / origin

A Ruby DSL for building MongoDB queries
http://mongoid.org/en/origin/index.html
MIT License
62 stars 29 forks source link

Complex values should be expanded when merging criterions using __multi__ strategy #75

Closed timershaziganshin closed 11 years ago

timershaziganshin commented 11 years ago

Complex keys (Origin::Key type) in and (or alias all_of) queries aren't expanding in raw queries correctly. Example:

class TestCriteria
  include Origin::Queryable
end

test_criteria = TestCriteria.new
test_criteria.and(:test.elem_match => {:test1.in => ["value1"]})

should build selector

{
  "$and"=> [
    {
      "test"=> {
        "$elemMatch"=> {
          "test1"=> {
            "$in"=> ["value1"]
          }
        }
      }
    }
  ]
}

but builds

{
  "$and"=> [
    {
      "test"=> {
        "$elemMatch"=> {
          #<Origin::Key:0x007feea0d8c868 @name=:test1, @strategy=:__intersect__, @operator="$in", @expanded=nil, @block=nil>=> ["value1"]           
        }
      }
    }
  ]
}