-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
See example:
import pymongo c = pymongo.Connection() db = c['test'] db['test'].drop() db['test'].ensure_index('a', unique=True) db['test'].insert({'a': '1', 'b': 1}, safe=True) try: db['test'].insert({'a': '1', 'b': 2}, safe=True) except pymongo.errors.DuplicateKeyError: print 'insert gives pymongo.errors.DuplicateKeyError' try: db['test'].find_and_modify(query={'a': '1', 'b': 2}, update={'$set': {'c': 1}}, upsert=True) except pymongo.errors.DuplicateKeyError: print 'find_and_modify gives pymongo.errors.DuplicateKeyError' except pymongo.errors.OperationFailure: print 'find_and_modify gives pymongo.errors.OperationFailure'
I would expect to get output
insert gives pymongo.errors.DuplicateKeyError find_and_modify gives pymongo.errors.DuplicateKeyError
but I get:
insert gives pymongo.errors.DuplicateKeyError find_and_modify gives pymongo.errors.OperationFailure