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

getLastError updatedExisting field should be set true when $set is used to add a new field.

    • ALL

      If a client uses $set to add a field to an existing document during an update, it should set updatedExisting to true in the last-error document, but only so sets updatedExisting when $set replaces an existing field.

      Expected behavior:

      connecting to: test
      > db.a.drop()
      > db.a.insert({_id: 1})
      > db.a.update({_id:1}, {a:2})
      > db.getLastErrorObj()
      {
      	"updatedExisting" : true,
      	"n" : 1,
      	"connectionId" : 6,
      	"err" : null,
      	"ok" : 1
      }
      > db.a.update({_id:1}, {a:3})
      > db.getLastErrorObj()
      {
      	"updatedExisting" : true,
      	"n" : 1,
      	"connectionId" : 6,
      	"err" : null,
      	"ok" : 1
      }
      

      Actual behavior:

      connecting to: test
      > db.a.drop()
      > db.a.insert({_id: 1})
      > db.a.update({_id:1}, {a:2})
      > db.getLastErrorObj()
      { "n" : 0, "connectionId" : 6, "err" : null, "ok" : 1 }
      > db.a.update({_id:1}, {a:3})
      > db.getLastErrorObj()
      {
      	"updatedExisting" : true,
      	"n" : 1,
      	"connectionId" : 6,
      	"err" : null,
      	"ok" : 1
      }
      

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: