-
Type: New Feature
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Shell
-
None
Normal "updateOne" requires "$" modifiers. However, bulk operation updateOne will allow a replacement (and this is documented). This violates the specification for bulk update (see test case 3).
This is inconsistent with updateOne in the shell and inconsistent with driver behaviors. We had a mongodb-user question because someone expected the (legacy) C++ driver behavior to match the shell's behavior.
Example (from kay.kim in discussions in DOCS-10009):
> db.items.insert( { } ) WriteResult({ "nInserted" : 1 }) > var bulk = db.items.initializeUnorderedBulkOp(); > bulk.find( { item: null } ).updateOne( ... { ... item: "TBD", ... points: 0, ... inStock: true, ... status: "I" ... } ... ); > bulk.execute(); BulkWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 0, "nUpserted" : 0, "nMatched" : 1, "nModified" : 1, "nRemoved" : 0, "upserted" : [ ] }) > db.items.find() { "_id" : ObjectId("58cbffadfb324641a8922d60"), "item" : "abc123", "defaultQty" : 100, "status" : "A", "points" : 100 } { "_id" : ObjectId("58cbffadfb324641a8922d61"), "item" : "ijk123", "defaultQty" : 200, "status" : "A", "points" : 200 } { "_id" : ObjectId("58cbffadfb324641a8922d62"), "item" : "mop123", "defaultQty" : 0, "status" : "P", "points" : 0 } { "_id" : ObjectId("58cbffd3fb324641a8922d63"), "item" : "TBD", "points" : 0, "inStock" : true, "status" : "I" }
This may not be worth fixing if SERVER-24002 goes forward.
- related to
-
SERVER-13092 shell bulk API replaceOne behaves like updateOne
- Closed
-
SERVER-48780 bulkWrite() in mongo shell does not check updates start with '$' and replacements do not
- Closed
-
SERVER-24002 Consider deprecating the bulk API in the mongo shell
- Closed