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

Update operator $max with multiple fields can modify wrong array element in 3.6

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.6.0-rc2
    • Fix Version/s: 3.6.0-rc5, 3.7.1
    • Component/s: Querying
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.6
    • Sprint:
      Query 2017-11-13, Query 2017-12-04

      Description

      Repro:

      db.test.insert({"x" : []});
      db.test.update({}, {$max: {"x.2.a": 1, "x.2.b": 1}});
       
      // 3.4: { "x" : [ null, null, { "a" : 1, "b" : 1 } ] }
      // 3.6: { "x" : [ null, null, { "a" : 1 }, { "b" : 1 } ] }
      

      The behavior on 3.6 gives the appearance that a different array element than the one specified was modified. In this case, the 3rd instead of the 2nd.

      The behavior on 3.4 seems to be correct.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tess.avitabile Tess Avitabile
              Reporter:
              robert.guo Robert Guo
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: