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 } ] }
- is related to
-
SERVER-33687 Sort order of array indexes can determine success of an update
- Closed
- related to
-
SERVER-31894 Update operator $max with multiple fields can modify wrong array element in 3.6
- Closed