[SERVER-198] $ne and $nin do not match docs lacking the searched field Created: 29/Jul/09  Updated: 12/Jul/16  Resolved: 06/Aug/09

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: 0.9.8

Type: Bug Priority: Minor - P4
Reporter: Mathias Stearn Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

> db.not.insert(

{a:1}

)
> db.not.insert(

{a:2}

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

{"_id" : ObjectId( "4a70d57450cc2b64ff07f162") , "a" : 1} {"_id" : ObjectId( "4a70d57650cc2b64ff07f163") , "a" : 2} {"_id" : ObjectId( "4a70d57850cc2b64ff07f164") }

> db.not.find(

{a:1}

)

{"_id" : ObjectId( "4a70d57450cc2b64ff07f162") , "a" : 1}

> db.not.find({a:{$ne:1}})

{"_id" : ObjectId( "4a70d57650cc2b64ff07f163") , "a" : 2}

> db.not.find({a:{$in:[1]}})

{"_id" : ObjectId( "4a70d57450cc2b64ff07f162") , "a" : 1}

> db.not.find({a:{$nin:[1]}})

{"_id" : ObjectId( "4a70d57650cc2b64ff07f163") , "a" : 2}

Note that the empty document is never found. This is surprising if you are expecting $nin to return all docs in the collection not returned by $in (same for $ne and $eq).



 Comments   
Comment by Eliot Horowitz (Inactive) [ 15/Aug/09 ]

Released in 0.9.8

Comment by Eliot Horowitz (Inactive) [ 06/Aug/09 ]


changed behaviour such that $in + $nin == total

Comment by Eliot Horowitz (Inactive) [ 06/Aug/09 ]

jstests/not1.js

Generated at Thu Feb 08 02:53:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.