-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Write Ops
-
Query Execution
-
ALL
When a multi update is applied to a collection where the operation is unable to be applied to all documents (e.g. a $inc on an array field), getLastError() returns "n" : 0 with the error but the operation still updates documents that it is able to update. The multi-update returns as soon as it fails to apply an operation.
Expected behavior: It should report "n" : `count of the number of documents it was able to update` as well as the error.
Actual behavior: Reports error and "n" : 0.
The example below updates 1/2 documents, but returns "n" : 0
>use test >db.c.insert({a:3,b:4}) >db.c.insert({a:[3,5],b:3}) >db.c.find() { "_id" : ObjectId("511d4e76242fb0dfc20856cc"), "a" : [ 3, 5 ], "b" : 3 } { "_id" : ObjectId("511d4e9f242fb0dfc20856cd"), "a" : 3, "b" : 4 } >db.c.update({}, {$inc:{a:1,b:6}}, {multi:true});db.getLastErrorObj(); { "err" : "Cannot apply $inc modifier to non-number", "code" : 10140, "n" : 0, "connectionId" : 1, "ok" : 1 } > db.c.find() { "_id" : ObjectId("511d4ed0242fb0dfc20856ce"), "a" : 4, "b" : 10 } { "_id" : ObjectId("511d4edd242fb0dfc20856cf"), "a" : [ 3, 5 ], "b" : 3 }