Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6147

aggregation $ne expression applied to constant returns incorrect result

    • ALL

      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 Matt Dannenberg
            Reporter:
            aaron Aaron Staple
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: