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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 3.6.0-rc5, 3.7.1
    • 3.6.0-rc2
    • Querying
    • Fully Compatible
    • ALL
    • v3.6
    • 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

        Activity

          People

            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: