[SERVER-6147] aggregation $ne expression applied to constant returns incorrect result Created: 20/Jun/12  Updated: 11/Jul/16  Resolved: 29/Jun/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Matt Dannenberg
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-6148 aggregation $ne expression applied to... Closed
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by auto [ 29/Jun/12 ]

Author:

{u'date': u'2012-06-22T08:51:47-07:00', u'email': u'dannenberg.matt@gmail.com', u'name': u'Matt Dannenberg'}

Message: SERVER-6147 fix aggro $ne to behave with constants
Branch: master
https://github.com/mongodb/mongo/commit/36c78176a97e52874850d38d08ac5f8019055325

Generated at Thu Feb 08 03:10:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.