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

findAndModify returns an empty document with "new" : true flag if the _id value in the query document does not match the _id value in the update document.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.8.4, 2.0.1
    • Fix Version/s: None
    • Component/s: Write Ops
    • Labels:
    • Operating System:
      ALL

      Description

      This is related to https://jira.mongodb.org/browse/SERVER-4157

      If the _id value in the query document does not match the _id value in the update document, an empty document will be returned.

      To reproduce: (in 1.8.4 or 2.0.1)

      > db.test.drop()
      true
      > db.test.findAndModify({ "query" :

      { "_id" : 0}

      , "update" :

      { "_id" : 1, "name" : "Object 1"}

      , "upsert" : true, "new" : true } );
      { } // an empty document is returned
      > db.test.find()

      { "_id" : 1, "name" : "Object 1" }

      > db.test.findAndModify({ "query" :

      { "_id" : 2, name:"blah"}

      , "update" :

      { "_id" : 2, "name" : "Object 2"}

      , "upsert" : true, "new" : true } );

      { "_id" : 2, "name" : "Object 2" }

      // the expected document is returned
      >

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eliot Eliot Horowitz (Inactive)
              Reporter:
              barrie Barrie Segal
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: