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

Failed update reports erroneous WriteResult

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: 2.6.4, 2.7.6
    • Fix Version/s: Backlog
    • Component/s: Write Ops
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      1. Insert test data

      db.test.insert({n: 1})
      db.test.insert({n: 2, age: 1})
      db.test.insert({n: 3})

      2. Update data with multi

      db.test.update({}, {$push: {age: 5}}, {multi: true})

      Result:

      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 0,
      	"nModified" : 0,
      	"writeError" : {
      		"code" : 16837,
      		"errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}"
      	}
      })

      Expected?:

      WriteResult({
      	"nMatched" : 3,
      	"nUpserted" : 0,
      	"nModified" : 1,
      	"writeError" : {
      		"code" : 16837,
      		"errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}"
      	}
      })

      Show
      1. Insert test data db.test.insert({n: 1}) db.test.insert({n: 2, age: 1}) db.test.insert({n: 3}) 2. Update data with multi db.test.update({}, {$push: {age: 5}}, {multi: true }) Result: WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 16837, "errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}" } }) Expected?: WriteResult({ "nMatched" : 3, "nUpserted" : 0, "nModified" : 1, "writeError" : { "code" : 16837, "errmsg" : "The field 'age' must be an array but is of type NumberDouble in document {_id: ObjectId('5419e06e44ceb57913a0b95a')}" } })

      Description

      See reproduction. The erroneous fields are nMatched and nModified.

      On a related note. The documentation on a collection update doesn't specify what happens when an update with multi fails on a specific document when more than one was matched.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-query Backlog - Query Team
              Reporter:
              eric.daniels Eric Daniels
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated: