Add SaveConditionError exception
This commit is contained in:
		| @@ -16,7 +16,8 @@ from mongoengine.base import ( | ||||
|     ALLOW_INHERITANCE, | ||||
|     get_document | ||||
| ) | ||||
| from mongoengine.errors import InvalidQueryError, InvalidDocumentError | ||||
| from mongoengine.errors import (InvalidQueryError, InvalidDocumentError, | ||||
|                                 SaveConditionError) | ||||
| from mongoengine.python_support import IS_PYMONGO_3 | ||||
| from mongoengine.queryset import (OperationError, NotUniqueError, | ||||
|                                   QuerySet, transform) | ||||
| @@ -359,7 +360,7 @@ class Document(BaseDocument): | ||||
|                     last_error = collection.update(select_dict, update_query, | ||||
|                                                    upsert=upsert, **write_concern) | ||||
|                     if not upsert and last_error['nModified'] == 0: | ||||
|                         raise OperationError('Race condition preventing' | ||||
|                         raise SaveConditionError('Race condition preventing' | ||||
|                                                  ' document update detected') | ||||
|                     created = is_new_object(last_error) | ||||
|  | ||||
|   | ||||
| @@ -41,6 +41,10 @@ class NotUniqueError(OperationError): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class SaveConditionError(OperationError): | ||||
|     pass | ||||
|  | ||||
|  | ||||
| class FieldDoesNotExist(Exception): | ||||
|     """Raised when trying to set a field | ||||
|     not declared in a :class:`~mongoengine.Document` | ||||
|   | ||||
		Reference in New Issue
	
	Block a user