|
"nModified" should be 0 in the following case, but it's 1:
> db.collection.find()
|
{ "_id" : 1, "a" : 1 }
|
> db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
|
{ "ok" : 1, "nModified" : 1, "n" : 1 }
|
nModified is 0 as expected if:
- the update uses $set instead of a whole-document replace
- the _id is an ObjectId instead of an integer
- the query is on a field besides _id
The behavior is intermittent, as seen in this shell session:
> db.collection.find()
|
{ "_id" : 1, "a" : 1 }
|
> db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
|
{ "ok" : 1, "nModified" : 1, "n" : 1 }
|
> db.collection.drop()
|
true
|
> db.collection.insert({_id: 1, a: 1})
|
WriteResult({ "nInserted" : 1 })
|
> db.runCommand({update: 'collection', updates: [{q: {_id: 1}, u: {_id: 1, a: 1}}]})
|
{ "ok" : 1, "nModified" : 0, "n" : 1 }
|
|