Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28383

Shell bulk.updateOne allows replacement

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Shell
    • None
    • Developer Tools

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-devtools DO NOT USE - Backlog - Dev Tools
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: