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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.2
    • Affects Version/s: 2.4.10, 2.6.1
    • Component/s: Write Ops
    • Labels:
      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

      > 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
      

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

              Created:
              Updated:
              Resolved: