missing field matches against [null] for both $in and $nin

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 2.1.0
    • Affects Version/s: 1.8.1
    • Component/s: Querying
    • Environment:
      Ubuntu 10.10 amd64
    • Minor Change
    • Linux
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As seen below when a field is missing from the document, a null value in the array returns true for both $in and $nin.

      If a missing value is equivalent to null, then $in is performing as expected and $nin should be returning false.

      > db.test.insert({})
      > db.test.find()

      { "_id" : ObjectId("4df8062a2c1a2033b886d0b5") }

      > db.test.find({"test": {$in: [null]}})

      { "_id" : ObjectId("4df8062a2c1a2033b886d0b5") }

      > db.test.find({"test": {$nin: [null]}})

      { "_id" : ObjectId("4df8062a2c1a2033b886d0b5") }

              Assignee:
              Aaron Staple (Inactive)
              Reporter:
              Sarva Bryant
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: