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

Change handling of nullish values in math expressions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.2
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Major Change
    • Operating System:
      ALL

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: