-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
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.
- is duplicated by
-
SERVER-6283 aggregate $cmp cannot be used with values of different numeric types
- Closed
- is related to
-
SERVER-6206 need a policy for incompatible types in operators in aggregation expressions
- Closed