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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.3
    • Affects Version/s: 2.0.2
    • Component/s: Querying
    • ALL

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: