Details
Description
The positional field name is not set when matching a negated expession (eg $ne, $nin, $not). So the $ positional operator does not work for these match expressions.
Test
c = db.c;
|
c.drop();
|
|
|
// $ operator works with equality match.
|
c.save( { a:[ 1, 2 ] } );
|
c.update( { a:1 }, { $set:{ 'a.$':3 } } );
|
printjson( c.findOne() );
|
|
|
// $ operator does not work with $ne match.
|
c.update( { a:{ $ne:10 } }, { $set:{ 'a.$':5 } } );
|
printjson( db.getLastError() ); // The '$' field name is not populated.
|
printjson( c.findOne() );
|
|
|
// $ operator does not work with $nin match.
|
c.update( { a:{ $nin:[ 10, 20 ] } }, { $set:{ 'a.$':5 } } );
|
printjson( db.getLastError() ); // The '$' field name is not populated.
|
printjson( c.findOne() );
|
|
|
// $ operator does not work with $not match.
|
c.update( { a:{ $not:{ $gt:7 } } }, { $set:{ 'a.$':5 } } );
|
printjson( db.getLastError() ); // The '$' field name is not populated.
|
printjson( c.findOne() );
|
Attachments
Issue Links
- depends on
-
SERVER-27089 Extend the update subsystem to support more expressive updates to array fields
-
- Closed
-
- duplicates
-
SERVER-27089 Extend the update subsystem to support more expressive updates to array fields
-
- Closed
-
- related to
-
DOCS-2580 Positional operator page should list negation limitation
-
- Closed
-