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

Failed update reports erroneous WriteResult

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.6.4, 2.7.6
    • Component/s: Write Ops
    • Query Execution
    • ALL
    • 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' )}" } })

      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.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            eric.daniels@mongodb.com Eric Daniels
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: