diff --git a/.gitignore b/.gitignore index b43bb3d1..f5766784 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ docs/_build #iPython *.ipynb + +cqlengine/tests/* +cqlengine/tests* \ No newline at end of file diff --git a/cqlengine/exceptions.py b/cqlengine/exceptions.py index 94a51b92..40663052 100644 --- a/cqlengine/exceptions.py +++ b/cqlengine/exceptions.py @@ -2,5 +2,6 @@ class CQLEngineException(Exception): pass class ModelException(CQLEngineException): pass class ValidationError(CQLEngineException): pass +class TransactionException(CQLEngineException): pass class UndefinedKeyspaceException(CQLEngineException): pass diff --git a/cqlengine/query.py b/cqlengine/query.py index e85771b5..406d4161 100644 --- a/cqlengine/query.py +++ b/cqlengine/query.py @@ -6,7 +6,7 @@ from cqlengine.columns import Counter, List, Set from cqlengine.connection import execute -from cqlengine.exceptions import CQLEngineException, ValidationError +from cqlengine.exceptions import CQLEngineException, ValidationError, TransactionException from cqlengine.functions import Token, BaseQueryFunction, QueryValue, UnicodeMixin #CQL 3 reference: @@ -836,6 +836,12 @@ class DMLQuery(object): return self._batch.add_query(q) else: tmp = execute(q, consistency_level=self._consistency) + if tmp and tmp[0].get('[applied]', True) is False: + tmp[0].pop('[applied]') + expected = ', '.join('{0}={1}'.format(t.field, t.value) for t in q.transactions) + actual = ', '.join('{0}={1}'.format(f, v) for f, v in tmp[0].items()) + message = 'Transaction statement failed: Expected: {0} Actual: {1}'.format(expected, actual) + raise TransactionException(message) return tmp def batch(self, batch_obj):