aggregation $ne expression applied to constant returns incorrect result

XMLWordPrintableJSON

    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Matt Dannenberg (Inactive)
            Reporter:
            Aaron Staple (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: