nModified wrong when replacing document and query on non-ObjectId _id

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: Write Ops
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      "nModified" should be 0 in the following case, but it's 1:

      > db.collection.find()
      { "_id" : 1, "a" : 1 }
      > db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
      { "ok" : 1, "nModified" : 1, "n" : 1 }
      

      nModified is 0 as expected if:

      • the update uses $set instead of a whole-document replace
      • the _id is an ObjectId instead of an integer
      • the query is on a field besides _id

      The behavior is intermittent, as seen in this shell session:

      > db.collection.find()
      { "_id" : 1, "a" : 1 }
      > db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
      { "ok" : 1, "nModified" : 1, "n" : 1 }
      > db.collection.drop()
      true
      > db.collection.insert({_id: 1, a: 1})
      WriteResult({ "nInserted" : 1 })
      > db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
      { "ok" : 1, "nModified" : 0, "n" : 1 }
      

            Assignee:
            Ramon Fernandez Marina
            Reporter:
            A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: