[SERVER-3264] missing field matches against [null] for both $in and $nin Created: 15/Jun/11  Updated: 12/Jul/16  Resolved: 14/Sep/11

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.8.1
Fix Version/s: 2.1.0

Type: Bug Priority: Major - P3
Reporter: Sarva Bryant Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 10.10 amd64


Backwards Compatibility: Minor Change
Operating System: Linux
Participants:

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

 Comments   
Comment by auto [ 13/Sep/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3264 additional test cases
Branch: master
https://github.com/mongodb/mongo/commit/44a265b7455e807c8da55324c0c0e5741cf7bfb3

Comment by auto [ 13/Sep/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-3264 make nin matching the opposite of in
Branch: master
https://github.com/mongodb/mongo/commit/e87dd3385c01372a7bbddd69bf9d09829788caf1

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