Shell bulk.updateOne allows replacement

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • 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.

            Assignee:
            DO NOT USE - Backlog - Dev Tools
            Reporter:
            David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: