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

Make $add operator type left associate for date in classic engine

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Minor Change
    • ALL
    • v6.0
    • QE 2022-09-05

      Currently $add always use widest numerical type to do summation, then cast to date type if there's a date element in the array.

      This is fine for all numeric types except date which could cause confusion:

      [1.5 + date + 1.5] can be either date + 3 or date + 4, the later one comes from round(round(date + 1.5) + 1.5).

       

      We should make the $add type left associate for date type, so when we are date to any number the result is casted to date, and following (right side) numbers are all added and casted to date type. code link

      (We will not backport this change to 6.0 or earlier)

      (this ticket is for classic engine, sbe change will be included in SERVER-67282)

       

            Assignee:
            zixuan.zhuang@mongodb.com Zixuan Zhuang
            Reporter:
            zixuan.zhuang@mongodb.com Zixuan Zhuang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: