Testing done against 2.5.5-pre (built off master)
git version: cec1b16a90acadf97b892a56fb15943a72f04398
// insert a few objects like this one > db.foo.findOne() { "_id" : ObjectId("52d4b437ec0439c7ad81e069"), "a" : 4 } // multi update with $mul works on all 4 > db.foo.update({}, {$mul : {a : 2}}, false, true) SingleWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 0, "nUpserted" : 0, "nUpdated" : 4, "nModified" : 4, "nRemoved" : 0, "upserted" : [ ] }) // now insert a string > db.foo.insert({a : "x"}) SingleWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 1, "nUpserted" : 0, "nUpdated" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }) // retry the update, expecting an error > db.foo.update({}, {$mul : {a : 2}}, false, true) SingleWriteResult({ "writeErrors" : [ [object Object] ], "writeConcernErrors" : [ ], "nInserted" : 0, "nUpserted" : 0, "nUpdated" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }) // checking the previous error gives us the actual error > db.getPrevError() { "err" : "Cannot apply $mul to a value of non-numeric type. {_id: ObjectId('52d4b44eec0439c7ad81e06d')} has the field 'a' of non-numeric type String", "code" : 16837, "n" : 0, "nPrev" : 2, "ok" : 1 }
It's also worth noting that the nUpdated and nModified values are 0 when in fact the multiply operation was successful. Evidence:
> db.foo.find() { "_id" : ObjectId("52d4b437ec0439c7ad81e069"), "a" : 64 } { "_id" : ObjectId("52d4b43aec0439c7ad81e06a"), "a" : 48 } { "_id" : ObjectId("52d4b43cec0439c7ad81e06b"), "a" : 32 } { "_id" : ObjectId("52d4b43dec0439c7ad81e06c"), "a" : 16 } { "_id" : ObjectId("52d4b44eec0439c7ad81e06d"), "a" : "x" } { "_id" : ObjectId("52d4b63dec0439c7ad81e06e"), "a" : "y" } > db.foo.update({}, {$mul : {a : 2}}, false, true) SingleWriteResult({ "writeErrors" : [ [object Object] ], "writeConcernErrors" : [ ], "nInserted" : 0, "nUpserted" : 0, "nUpdated" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }) // 0 modified or updated, but if we check the values again we can see the successful modification of the 4 numeric fields > db.foo.find() { "_id" : ObjectId("52d4b437ec0439c7ad81e069"), "a" : 128 } { "_id" : ObjectId("52d4b43aec0439c7ad81e06a"), "a" : 96 } { "_id" : ObjectId("52d4b43cec0439c7ad81e06b"), "a" : 64 } { "_id" : ObjectId("52d4b43dec0439c7ad81e06c"), "a" : 32 } { "_id" : ObjectId("52d4b44eec0439c7ad81e06d"), "a" : "x" } { "_id" : ObjectId("52d4b63dec0439c7ad81e06e"), "a" : "y" }