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

Queryable::Selector#merge! does not properly handle :$in/:$nin keys

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 9.0.0, 8.0.6, 8.1.2, 7.5.4
    • Affects Version/s: None
    • Component/s: None
    • None

      Mongoid::Criteria::Queryable::Selector#merge! does not correctly merge $in and $nin when provided as a symbol as well as a string.

      selector = Mongoid::Criteria::Queryable::Selector.new
      selector['field'] = { :$in => [1,2] }
      selector.merge!( 'field' => { :$in => [3] })
      selector # => {"field"=>{:$in=>[3]}}, while it should be {"field"=>{:$in=>[]}}
      

      Issue was introduced with PR-4645.
      Behaviour before allowed $in and $nin to be provided as symbols or strings and would match correctly.
      After PR-4645 only $in or $nin strings would be merged.

            Assignee:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Reporter:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: