-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.6.4
-
Component/s: Write Ops
-
None
-
ALL
Not sure if this is related to https://jira.mongodb.org/browse/SERVER-14886 or not, but updates to an embedded document in an array can cause an insertion to happen in 2.6.4 but the correct update in 2.4.10.
db.test.insert({ root: [ { _id: "A", children: [ {_id: "C", name: "Alice"} ] }, { _id: "B", children: [ {_id: "D", name: "Bob"} ] } ] })
To update Bob's name to Carol, I can issue:
db.test.update({"root._id": "B", "root.1.children._id": "D"}, {$set: {"root.1.children.$.name": "Carol"}})
In 2.4, this update's Bob's name to Carol. In 2.6.4, this INSERTS Carol:
mongos> db.test.find({}).pretty() { "_id" : ObjectId("547f72c1e52e8693ed137ad6"), "root" : [ { "_id" : "A", "children" : [ { "_id" : "C", "name" : "Alice" } ] }, { "_id" : "B", "children" : [ { "_id" : "D", "name" : "Bob" }, { "name" : "Carol" } ] } ] }
Note that if you drop the
{"root._id": "B"} part of the clause in the update, you get the 'The positional operator did not find the match needed from the query' error from SERVER-14886.
- duplicates
-
SERVER-14886 Updates against paths composed with array index notation and positional operator fail with error
- Closed
-
SERVER-14662 Positional projection queries (and positional update ops) should fail with error if multiple arrays encountered
- Closed
- related to
-
SERVER-14886 Updates against paths composed with array index notation and positional operator fail with error
- Closed