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

UpdatedExisting always true after update command

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.5.4
    • 2.5.5
    • None
    • None
    • Fully Compatible
    • 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

              randolph@mongodb.com Randolph Tan
              bernie@mongodb.com Bernie Hackett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: