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

findAndModify() cannot take an empty update object, but update() can

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.4.10, 2.6.1
    • 2.7.2
    • Write Ops
    • None
    • ALL
    • Hide

      > db.foo.update({},{},true)
      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 1,
      	"nModified" : 0,
      	"_id" : ObjectId("536beb62fe2ac487fb241614")
      })
       
      > db.foo.findAndModify({query:{_id: ObjectId("536beb62fe2ac487fb241614")},update:{},upsert:true})
      2014-05-08T17:10:23.774-0400 findAndModifyFailed failed: { "ok" : 0, "errmsg" : "need remove or update" } at src/mongo/shell/collection.js:614

      Show
      > db.foo.update({},{},true) WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : ObjectId("536beb62fe2ac487fb241614") })   > db.foo.findAndModify({query:{_id: ObjectId("536beb62fe2ac487fb241614")},update:{},upsert:true}) 2014-05-08T17:10:23.774-0400 findAndModifyFailed failed: { "ok" : 0, "errmsg" : "need remove or update" } at src/mongo/shell/collection.js:614

    Description

      > db.foo.update({},{},true)
      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 1,
      	"nModified" : 0,
      	"_id" : ObjectId("536beb62fe2ac487fb241614")
      })
       
      > db.foo.findAndModify({query:{_id: ObjectId("536beb62fe2ac487fb241614")},update:{},upsert:true})
      2014-05-08T17:10:23.774-0400 findAndModifyFailed failed: { "ok" : 0, "errmsg" : "need remove or update" } at src/mongo/shell/collection.js:614

      Attachments

        Issue Links

          Activity

            People

              rassi J Rassi
              matt.dannenberg Matt Dannenberg
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: