[SERVER-3143] Matching null against an empty array behaves differently without an index Created: 25/May/11  Updated: 29/Feb/12  Resolved: 14/Dec/11

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

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-3375 key generation fixes master ticket Closed
Operating System: ALL
Participants:

 Description   

I think the behavior with an index is correct (or at least desirable) here.

> db.foo.drop()
true
> db.foo.insert(

{a:[]}

)
> db.foo.find(

{a:null}

)
> db.foo.ensureIndex(

{a:1}

)
> db.foo.find(

{a:null}

)

{ "_id" : ObjectId("4ddd6ebe90a1203088d20f68"), "a" : [ ] }

 Comments   
Comment by Aaron Staple [ 14/Dec/11 ]

Just came across this ticket. For SERVER-3375 we fixed a number of things, including this inconsistency. As part of the change we made null not match [] (so went with the earlier behavior when matching without an index). If you'd like a null query to match an empty array, I'd recommend filing a separate ticket for that.

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