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

bulkWrite() in mongo shell does not check updates start with '$' and replacements do not

    • Type: Icon: Bug Bug
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Server Development Platform
    • ALL
    • Hide

      The following should all throw a JavaScript exception without executing the command on the server:

      db.mycoll.bulkWrite([{replaceOne: {filter: {}, replacement: {$set: {a: 1}}}}])
      db.mycoll.bulkWrite([{updateOne: {filter: {}, update: {field: 1}}}])
      db.mycoll.bulkWrite([{updateMany: {filter: {}, update: {field: 1}}}])
      
      Show
      The following should all throw a JavaScript exception without executing the command on the server: db.mycoll.bulkWrite([{replaceOne: {filter: {}, replacement: {$set: {a: 1}}}}]) db.mycoll.bulkWrite([{updateOne: {filter: {}, update: {field: 1}}}]) db.mycoll.bulkWrite([{updateMany: {filter: {}, update: {field: 1}}}])

      DBCollection.prototype.replaceOne() validates the replacement document contains at least one non-$operator field. DBCollection.prototype.updateOne() and DBCollection.prototype.updateMany() validate the update object contains at least one $operator field.

      However, none of replaceOne, updateOne, or updateMany in DBCollection.prototype.bulkWrite() do the same.

            Assignee:
            backlog-server-devplatform [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: