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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.1.0
    • 1.8.1
    • Querying
    • Ubuntu 10.10 amd64
    • Minor Change
    • Linux

    Description

      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") }

      Attachments

        Activity

          People

            aaron Aaron Staple
            sarva Sarva Bryant
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: