Details
Description
If a client uses $set to add a field to an existing document during an update, it should set updatedExisting to true in the last-error document, but only so sets updatedExisting when $set replaces an existing field.
Expected behavior:
connecting to: test
|
> db.a.drop()
|
> db.a.insert({_id: 1})
|
> db.a.update({_id:1}, {a:2})
|
> db.getLastErrorObj()
|
{
|
"updatedExisting" : true,
|
"n" : 1,
|
"connectionId" : 6,
|
"err" : null,
|
"ok" : 1
|
}
|
> db.a.update({_id:1}, {a:3})
|
> db.getLastErrorObj()
|
{
|
"updatedExisting" : true,
|
"n" : 1,
|
"connectionId" : 6,
|
"err" : null,
|
"ok" : 1
|
}
|
Actual behavior:
connecting to: test
|
> db.a.drop()
|
> db.a.insert({_id: 1})
|
> db.a.update({_id:1}, {a:2})
|
> db.getLastErrorObj()
|
{ "n" : 0, "connectionId" : 6, "err" : null, "ok" : 1 }
|
> db.a.update({_id:1}, {a:3})
|
> db.getLastErrorObj()
|
{
|
"updatedExisting" : true,
|
"n" : 1,
|
"connectionId" : 6,
|
"err" : null,
|
"ok" : 1
|
}
|