|
Observed behavior: A simple query on _id with a positional operator projection on another field returns an incorrect result based on a missing positional match.
Expected behavior: Same behavior as if it is not a simple query on _id and there is no query field matching the positional operator - uassert.
Test
c = db.c;
|
c.drop();
|
|
c.save( { _id:0, a:[ 1, 2 ] } );
|
|
// Throws error.
|
c.find( {}, { 'a.$':1 } ).toArray();
|
|
// Should throw but instead returns a result I think is incorrect.
|
printjson( c.find( { _id:0 }, { 'a.$':1 } ).toArray() );
|
We should also ensure that in cases where a positional operator is used, a match details is always available. We could check this with an assertion.
|