Change handling of nullish values in math expressions

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 2.3.2
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Major Change
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Mathias Stearn
            Reporter:
            Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: