|
ExpressionCompare::optimize() generates an ExpressionFieldRange for a $ne comparison against a constant. However ExpressionCompare does not properly encapsulate the semantics of not equals matching.
Test:
c = db.c;
|
c.drop();
|
|
c.save( { a:1, b:1 } );
|
c.save( { a:2, b:1 } );
|
printjson( c.aggregate( { $project:{ z:{ $ne:[ '$a', 1 ] } } } ) );
|
printjson( c.aggregate( { $project:{ z:{ $ne:[ '$a', '$b' ] } } } ) );
|
Observed behavior
{ $ne:[ '$a', 1 ] }
is always false
Actual behavior
{ $ne:[ '$a', 1 ] }
should be true when the 'a' field value != 1.
|