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

$set: {} is now rejected by the update framework, but worked as a noop prior to 2.6

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.1
    • Component/s: Write Ops
    • Labels:
      None
    • ALL
    • Hide
      > db.runCommand({ findAndModify: "foo", query:{_id: ObjectId("536beb62fe2ac487fb241614")}, update:{$set : {} }, upsert:true} )
      {
      	"value" : null,
      	"errmsg" : "exception: '$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}",
      	"code" : 9,
      	"ok" : 0
      }
      > db.foo.update({_id: ObjectId("536beb62fe2ac487fb241614")},{$set:{}},true)
      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 0,
      	"nModified" : 0,
      	"writeError" : {
      		"code" : 9,
      		"errmsg" : "'$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}"
      	}
      })
      
      Show
      > db.runCommand({ findAndModify: "foo" , query:{_id: ObjectId( "536beb62fe2ac487fb241614" )}, update:{$set : {} }, upsert: true } ) { "value" : null , "errmsg" : "exception: '$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}" , "code" : 9, "ok" : 0 } > db.foo.update({_id: ObjectId( "536beb62fe2ac487fb241614" )},{$set:{}}, true ) WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 9, "errmsg" : " '$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}" } })

      > db.runCommand({ findAndModify: "foo", query:{_id: ObjectId("536beb62fe2ac487fb241614")}, update:{$set : {} }, upsert:true} )
      {
      	"value" : null,
      	"errmsg" : "exception: '$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}",
      	"code" : 9,
      	"ok" : 0
      }
      > db.foo.update({_id: ObjectId("536beb62fe2ac487fb241614")},{$set:{}},true)
      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 0,
      	"nModified" : 0,
      	"writeError" : {
      		"code" : 9,
      		"errmsg" : "'$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}"
      	}
      })
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dannenberg Matt Dannenberg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: