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

$ne has inconsistent behavior

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 3.4.9
    • None
    • 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 }}})

    Description

      `$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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: