Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-31876

$ne has inconsistent behavior

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.9
    • Component/s: Querying
    • None
    • Query
    • ALL
    • Hide
      >db.inventory.insertMany([
      { "a" : [ ] },
      { "a" : [ {}] },
      { "a" : [ { "b" : 1}, { "d" : 1 } ] }
      ])
      >db.inventory.find({'a.b':{$ne:null}})
      >db.inventory.find({'a.b':{$elemMatch:{$ne:null}}})
      
      Show
      >db.inventory.insertMany([ { "a" : [ ] }, { "a" : [ {}] }, { "a" : [ { "b" : 1}, { "d" : 1 } ] } ]) >db.inventory.find({ 'a.b' :{$ne: null }}) >db.inventory.find({ 'a.b' :{$elemMatch:{$ne: null }}})

      `$ne` has very inconsistent behavior when used with arrays. This behavior also differs when using `$elemMatch`, while the `$elemMatch` docs state that with one query, the results should be identical.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            jjaco16 Johnny
            Votes:
            2 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: