shell bulk API replaceOne behaves like updateOne

XMLWordPrintableJSON

    • Server Development Platform
    • ALL
    • Hide

      The following code should fail but instead it updates the

      {a:0}

      document.

      var coll = db.foo;
      var batch = coll.initializeOrderedBulkOp();
      batch.insert({a:0});
      batch.find({a:0}).replaceOne({$set: {b:2}});
      var result = batch.execute();
      
      Show
      The following code should fail but instead it updates the {a:0} document. var coll = db.foo; var batch = coll.initializeOrderedBulkOp(); batch.insert({a:0}); batch.find({a:0}).replaceOne({$set: {b:2}}); var result = batch.execute();
    • Build A (10/09/15), Build B (10/30/15)
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      According to the fluent API spec https://github.com/10gen/specifications/blob/master/source/driver-fluent-api.rst

      replaceOne should always replace and never update a document. This should be ensured by checking that the new document is not prefixed with '$'.

      This is currently not enforced in the shell bulk API implementation. replaceOne calls updateOne directly without any extra checks.

              Assignee:
              [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
              Reporter:
              Andreas Nilsson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: