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

findAndModify should tolerate _id in update field if it doesn't modify it

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: None
    • Component/s: Write Ops

      findAndModify currently throws a "Mod on _id not allowed" error if update contains an _id, even when the query would not actually change the _id of the document, or a new document would be created.

      findAndModify instead should only throw an error if it has ascertained that a matched document has a different _id as the one specified in the query.

      this applies especially when one uses findAndModify as a way to do a 'save' (ie, an upsert) with a unique key different than _id. in that case the _id would never be changed, but still one is forced to take care of removing the _id from the document when saving it.

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            vincentcr Vincent Côté-Roy
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: