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

    XMLWordPrintable

Details

    • Bug
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • None
    • None
    • Shell
    • 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}}}])

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
              max.hirschhorn@mongodb.com Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: