Info
Versions 2.4 and 2.5 of MongoDB return different results when performing a query on a sub-document stored in a field that has a numeric name that happens to be the value of the index at which that document is stored within an array field.
Top User Comments
dan@10gen.com commented on Mon, 9 Dec 2013 03:43:21 +0000:
benety.goh, can you add a unit test which documents this behavior.
Steps to Reproduce
2.4.9-pre-
> db.c.insert({a:[{"0":{b:"Hello"}}]})
> db.c.find({"a.0.b":"Hello"})
>
Compare that to 2.5.5-pre-:
> db.c.insert({a:[{"0":{b:"Hello"}}]})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> db.c.find({"a.0.b":"Hello"})
{ "_id" : ObjectId("52a10cd0dd47ad0373e22ae6"), "a" : [ { "0" : { "b" : "Hello" } } ] }
>