| Steps To Reproduce: |
When an update command results in a writeError (e.g. duplicate key) the nModified field is no longer returned (tested against master, standalone):
>>> c.test.test.create_index('a', unique=True)
|
u'a_1'
|
>>> c.test.command('insert', 'test', documents=[{'_id': 1, 'a': 1}])
|
{u'ok': 1, u'n': 1}
|
>>> c.test.command('insert', 'test', documents=[{'_id': 2}])
|
{u'ok': 1, u'n': 1}
|
>>> try:
|
... c.test.command('update', 'test', updates=[SON([('q', {'_id':
|
2}), ('u', {'$set': {'a': 1}}), ('upsert', False), ('multi',
|
False)])])
|
... except Exception, exc:
|
... print exc.details
|
...
|
{u'writeErrors': [{u'index': 0, u'code': 11000, u'errmsg': u'E11000
|
duplicate key error index: test.test.$a_1 dup key: { : 1 }'}], u'ok':
|
1, u'n': 0}
|
Rolling mongo master back about a day, we have this behavior (which I think is correct):
>>> try:
|
... c.test.command('update', 'test', updates=[SON([('q', {'_id':
|
2}), ('u', {'$set': {'a': 1}}), ('upsert', False), ('multi',
|
False)])])
|
... except Exception, exc:
|
... print exc.details
|
...
|
{u'nModified': 0, u'writeErrors': [{u'index': 0, u'code': 11000,
|
u'errmsg': u'E11000 duplicate key error index: test.test.$a_1 dup
|
key: { : 1 }'}], u'ok': 1, u'n': 0}
|
|