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

GLE upserted _id field should always be filled in

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.3
    • Component/s: Write Ops
    • Labels:
      None

      Description

      the id isn't included in at least two cases where it probably should for consistency

      if the _id wasn't generated server-side:
      > db.foo.update({_id:'asdf'}, {$set: {a:'123'}}, true)
      > db.getLastErrorObj()

      { "err" : null, "updatedExisting" : false, "n" : 1, "ok" : true }

      > db.foo.update(

      {a:'asdf'}

      , {_id: 'qwer'}, true)
      > db.getLastErrorObj()

      { "err" : null, "updatedExisting" : false, "n" : 1, "ok" : true }

      if the object already existed:

      > db.foo.update({_id:{$gt: ObjectId("4c2e342e38535540224f7945")}}, {$set: {a:'123'}}, true)
      > db.getLastErrorObj()

      { "err" : null, "updatedExisting" : false, "upserted" : ObjectId("4c2e346538535540224f7946"), "n" : 1, "ok" : true }

      > db.foo.update({_id:{$gt: ObjectId("4c2e342e38535540224f7945")}}, {$set: {a:'123'}}, true)
      > db.getLastErrorObj()

      { "err" : null, "updatedExisting" : true, "n" : 1, "ok" : true }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              scotthernandez Scott Hernandez
              Reporter:
              redbeard0531 Mathias Stearn
              Participants:
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: