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

Criteria with #matches keys aren't merged

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

      The #matches criteria are overwritten instead of being merged

      Post.where(:comments.matches => {author: /asdf/}).
           where(:comments.matches => {body: /asdf/})
      # => #<Mongoid::Criteria
      #  selector: {:comments=>{"$elemMatch"=>{:body=>/asdf/}}},
      #  options:  {},
      #  class:    Post,
      #  embedded: false>
      
      Post.where(:comments.matches => {body: /asdf/}).
           where(:comments.matches => {author: /asdf/})
      # => #<Mongoid::Criteria
      #  selector: {:comments=>{"$elemMatch"=>{:author=>/asdf/}}},
      #  options:  {},
      #  class:    Post,
      #  embedded: false>
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            elia Elia Schito
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: