-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
When you query for a value on each of two arrays, both with positional operators, the $ projection operator can get pretty confused but smoothly performs the wrong operation.
Steps to reproduce:
Perform the following operations in the shell:
db.foo.insert( { a : [5, 6, 7, 8], b : [ 11, 12, 13, 14] } )
db.foo.find( { a : 7, b : 11 }, { "a.$" : 1 , _id : 0 }
Expected result:
{ "a" : 7 }or an exception
Actual result :
{ "a" : 5 }Related documentation:
The following doc tells me not to do exactly what I did: http://docs.mongodb.org/manual/reference/operator/projection/positional/#proj._S_
"Only one array field can appear in the query document; i.e. the following query is incorrect:" (then the example shows me exactly what I did), but this is clearly a case where either an exception should be thrown, or else the $ operator should be made smarter.
- duplicates
-
SERVER-1013 positional $ operator field mismatch
- Closed