-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Replication
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I want to bring to light the continually changing behavior of applyOps with an "invalid" update. This is probably working as designed but I want to confirm that the changes are intentional.
The "invalid" update is attempting to set an array element on a field that is set to null (not an array). See the attached applyOps.js
for the repro.
On 3.2 the server reports success and applies the update:
$ mongo applyOps.js
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.2.18
WARNING: shell and server versions do not match
doc before: { "_id" : 1, "a" : null }
applyOps result: { "applied" : 2, "results" : [ true, true ], "ok" : 1 }
doc after : { "_id" : 1, "a" : { "0" : 2 } }
On 3.4 the server reports an error and does not apply the update:
$ mongo applyOps.js
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.18
WARNING: shell and server versions do not match
doc before: { "_id" : 1, "a" : null }
applyOps result: {
"applied" : 1,
"code" : 16837,
"codeName" : "Location16837",
"errmsg" : "cannot use the part (a of a.0) to traverse the element ({a: null})",
"results" : [
false
],
"ok" : 0
}
doc after : { "_id" : 1, "a" : null }
On 3.6, the server reverts back to the 3.2 behavior, reports success and applies the update:
$ mongo applyOps.js
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.9
WARNING: shell and server versions do not match
doc before: { "_id" : 1, "a" : null }
applyOps result: { "applied" : 2, "results" : [ true, true ], "ok" : 1 }
doc after : { "_id" : 1, "a" : { "0" : 2 } }
Finally on 4.0, the server reports success and does not apply the update:
$ mongo applyOps.js
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.4
doc before: { "_id" : 1, "a" : null }
applyOps result: { "applied" : 2, "results" : [ true, true ], "ok" : 1 }
doc after : { "_id" : 1, "a" : null }
- duplicates
-
SERVER-38860 Positional array update behavior of applyOps on invalid field varies on different versions
-
- Closed
-
- is related to
-
SERVER-38860 Positional array update behavior of applyOps on invalid field varies on different versions
-
- Closed
-