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

$ne has inconsistent behavior

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 3.4.9
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

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

                Dates

                Created:
                Updated:
                Resolved: