[SERVER-5481] query on undefined field matches empty array Created: 02/Apr/12  Updated: 11/Jul/16  Resolved: 14/Dec/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-1160 {a: undefined} broken with index Closed
is related to SERVER-12024 re-implement $in in terms of $or Backlog
is related to SERVER-5063 $in on first compound key element and... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

In some cases it is possible to query for the undefined type. If full document matching is bypassed, such a query can match an empty array, which is stored in the index using the undefined type.

> c.ensureIndex( { a:1 } )
> c.save( { a:[] } )
> c.find( { a:{ $in:[ undefined ] } } )
{ "_id" : ObjectId("4f7a117c37365e9167f24ed3"), "a" : [ ] }
> 



 Comments   
Comment by Githook User [ 17/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-5481 reject $in query on undefined value
Branch: master
https://github.com/mongodb/mongo/commit/4a6d915d378bfbd1dc03796db80c85f846c68bc9

Comment by Githook User [ 14/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: Revert: SERVER-5481 reject $in query on undefined value
Branch: master
https://github.com/mongodb/mongo/commit/7c72e8b52934f2daedeee4f289c75246dc665487

Comment by Githook User [ 14/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-5481 reject $in query on undefined value
Branch: master
https://github.com/mongodb/mongo/commit/6c398c64c723f0521a225dddf2c0bfb53658c39b

Comment by Eliot Horowitz (Inactive) [ 11/Apr/12 ]

I'm ok with this behavior.

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