Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
ALL
Description
Original Title: dividing by zero makes field disappear
ExpressionDivide returns Undefined on divide by zero, which causes the field to be dropped. Might be more appropriate to return +/- Infinity or NaN.
c = db.c;
|
c.drop();
|
|
|
c.save( { a:NumberLong(10) } );
|
printjson( c.aggregate( { $project:{ z:{ $divide:[ '$a', 0 ] } } } ) );
|
Observed behavior: A field is removed on attempt to set its value to the output of a division by zero.
Expected behavior: The field is set to an appropriate value ( see above ) rather than removed.
The same occurs when attempting to mod by zero:
c.save( { a:NumberLong(10) } );
|
printjson( c.aggregate( { $project:{ z:{ $mod:[ '$a', 0 ] } } } ) );
|
Attachments
Issue Links
- related to
-
SERVER-29410 Enhance aggregation to handle handle NaN and +/- infinity
-
- Backlog
-