Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2206

elem_match with lte produces incorrect selector

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.2
    • Affects Version/s: None
    • Component/s: None
    • None

      Vote.where(:"versions".elem_match => { :updated_at.lte => Time.now.utc})
      => #<Mongoid::Criteria
        selector: {"versions"=>{"$elemMatch"=>

      {#<Origin::Key:0x00000004ef1b50 @name=:updated_at, @strategy=:__override__, @operator="$lte", @expanded=nil, @block=nil>=>2012-07-17 08:12:34 UTC}

      }},
        options: {},
        class: Vote,
        embedded: false>

      This return empty results

      Vote.where(:"versions".elem_match => { :updated_at => { :$lte => Time.now.utc} })
      => #<Mongoid::Criteria
        selector: {"versions"=>{"$elemMatch"=>{:updated_at=>{:$lte=>2012-07-17 08:12:44 UTC}}}},
        options: {},
        class: Vote,
        embedded: false>

      This however returns correct result. Is it no longer possible to use first approach ?

            Assignee:
            Unassigned Unassigned
            Reporter:
            kbackowski kbackowski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: