-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: MongoDB 3.2
-
Environment:windows 10
mongo 3.2.10
-
Empty show more show less
When the 'spaces' field is an array, the queries fail to project i18n.$ correctly, ('en' is always returned)
It's maybe fixed since 3.4, but submitting it in case it's not
> db.u.find() > db.u.insert({spaces:['foo'], i18n:[{l:'en',x:1}, {l:'de', x:3}]}) WriteResult({ "nInserted" : 1 }) > db.u.insert({spaces:['bar'], i18n:[{l:'en',x:2}, {l:'de', x:4}]}) WriteResult({ "nInserted" : 1 }) > db.u.find({spaces:'bar', 'i18n.l':'en'}, {'i18n.$':1, spaces:1}) { "_id" : ObjectId("58ad69e98d62dac604e9b186"), "spaces" : [ "bar" ], "i18n" : [ { "l" : "en", "x" : 2 } ] } > db.u.find({spaces:'bar', 'i18n.l':'de'}, {'i18n.$':1, spaces:1}) { "_id" : ObjectId("58ad69e98d62dac604e9b186"), "spaces" : [ "bar" ], "i18n" : [ { "l" : "en", "x" : 2 } ] } > db.u.drop() true > db.u.find() > db.u.insert({spaces:'foo', i18n:[{l:'en',x:1}, {l:'de', x:3}]}) WriteResult({ "nInserted" : 1 }) > db.u.insert({spaces:'bar', i18n:[{l:'en',x:2}, {l:'de', x:4}]}) WriteResult({ "nInserted" : 1 }) > db.u.find({spaces:'bar', 'i18n.l':'de'}, {'i18n.$':1, spaces:1}) { "_id" : ObjectId("58ad6afbd58e080a9eb86638"), "spaces" : "bar", "i18n" : [ { "l" : "de", "x" : 4 } ] } > db.u.find({spaces:'bar', 'i18n.l':'en'}, {'i18n.$':1, spaces:1}) { "_id" : ObjectId("58ad6afbd58e080a9eb86638"), "spaces" : "bar", "i18n" : [ { "l" : "en", "x" : 2 } ] }