-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Major Change
-
ALL
Currently when a nullish (missing/EOO, Undefined, or Null) value is used in a math expression such as $add, we treat it as 0. I think a better behavior would be to make the output always be NULL if any input value is nullish. If users want the old behavior, they can use $ifNull:
{$mulitply: [10, '$value']} -> {$multiply:[10, {$ifNull:['$value', 0]}]}
Note: this change only applies to the expressions $add, $multiply, $subtract, etc. The $group accumulators ($min, $max, $sum, and $avg) will continue to ignore nullish values.