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

$not should return error if used as a top-level key in query document

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.5.3
    • Component/s: Querying
    • Labels:
    • Operating System:
      ALL

      Description

      Given a small collection with these values:

      > db.test.find()
      { "_id" : ObjectId("4f3ade128e2fc474150d9afd"), "x" : 1, "y" : 2 }
      { "_id" : ObjectId("4f3ade168e2fc474150d9afe"), "x" : 3, "y" : 4 }
      { "_id" : ObjectId("4f3adec28e2fc474150d9aff"), "x" : 5, "y" : 6 }
      >

      This simple query gives the obvious results:

      > db.test.find({x:1,y:2})
      { "_id" : ObjectId("4f3ade128e2fc474150d9afd"), "x" : 1, "y" : 2 }
      >

      But why doesn't this query using $not work?

      > db.test.find({$not:{x:1,y:2}})
      >

      I expected it to simply return all the documents that didn't match the first time.

      If this usage of $not is not supported then an error should be returned.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: