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

ExpressionCompare::evaluate does not use Value::compare, does not handle heterogenous types (including numeric types) and some other comparison cases

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.0-rc1
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      ExpressionCompare::evaluate cannot compare different types (including numeric types) and cannot compare some types at all (eg objects). Lacks some functionality of Value::compare.

      Test

      c = db.c;
      c.drop();
      
      c.save( { a:1, b:NumberLong(1) } );
      c.save( { a:NumberLong(1), b:NumberLong(1) } );
      c.save( { a:{q:1}, b:{q:1} } );
      printjson( c.aggregate( { $project:{ z:{ $eq:[ '$a', '$b' ] } } } ) );
      

      There are also some todo comments:

              /* TODO look into collapsing by using Value::compare() */
      
              // CW TODO at least for now.  later, handle automatic conversions
      

      Observed behavior: An assertion occurs when an attempt is made to compare numbers of different numeric types with an aggregation expression.
      Expected behavior: Different numeric types can be compared.

            Assignee:
            matt.dannenberg Matt Dannenberg
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: