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

UpdatedExisting always true after update command

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.5.4
    • Fix Version/s: 2.5.5
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL

      Description

      getLastError appears to always return true for updatedExisting when the last operation was an update, regardless of whether a document was updated or not.

      > db.test.remove()
      SingleWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 0,
      	"nUpserted" : 0,
      	"nUpdated" : 0,
      	"nModified" : 0,
      	"nRemoved" : 2,
      	"upserted" : [ ]
      })
      > db.test.insert({i: 1})
      SingleWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 1,
      	"nUpserted" : 0,
      	"nUpdated" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
      > db.test.update({i: 5}, {$set: {i: 500}})
      SingleWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 0,
      	"nUpserted" : 0,
      	"nUpdated" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
      > db.runCommand('getLastError')
      {
      	"updatedExisting" : true,
      	"n" : 0,
      	"connectionId" : 2291,
      	"syncMillis" : 0,
      	"writtenTo" : null,
      	"err" : null,
      	"ok" : 1
      }
      > db.test.find()
      { "_id" : ObjectId("52d07a4cd05c85fb8d3f5e3d"), "i" : 1 }
      > db.test.update({i: 5}, {$set: {i: 1}})
      SingleWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 0,
      	"nUpserted" : 0,
      	"nUpdated" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
      > db.runCommand('getLastError')
      {
      	"updatedExisting" : true,
      	"n" : 0,
      	"connectionId" : 2291,
      	"syncMillis" : 0,
      	"writtenTo" : null,
      	"err" : null,
      	"ok" : 1
      }
      > db.test.find()
      { "_id" : ObjectId("52d07a4cd05c85fb8d3f5e3d"), "i" : 1 }

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: