-
Type: Bug
-
Resolution: Incomplete
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Labels:None
-
ALL
-
Combining a positional operator in the projection with some other array dotted field returns:
"BadValue: positional operator element mismatch"
Example:
db.collection.find({ "my_array" : { $elemMatch : { "key1" : "value1", "key2" : "value2" } } }, { "my_array.$" : 1, "some_other_array.other_field" : 1 })
returns the error message.
db.collection.find({ "my_array" : { $elemMatch : { "key1" : "value1", "key2" : "value2" } } }, { "my_array.$" : 1 })
returns the expected result.
According to the docs at:
https://docs.mongodb.com/manual/reference/operator/projection/positional/
Only one array field, the one being limited with the $ projection operator, should appear in the query document. Additional array fields in the query document may lead to undefined behavior
But there is no similar limit on the projection document.