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

Update operator $min handles non-existent array elements differently in 3.6

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.17, 3.4.10
    • Component/s: Querying
    • Labels:
    • Query
    • ALL

      The `$min` update operator did not update certain non-existent array elements in 3.4 and 3.2, which is no longer the case in 3.6. The behavior under 3.6 seems to be the more correct one.

      db.test.insert({"_id": "unique", "a": [],});
      db.test.update({}, {"$min": {"a.1": {"x": 1}, "a.0": {"y": 1, }}});
      
      // 3.6: {  "_id" : "unique",  "a" : [ { "y" : 1 }, { "x" : 1 } ] }
      // 3.4 and prior: {  "_id" : "unique",  "a" : [ null, { "x" : 1 } ] }
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: