|
5 | 5 | from cqlengine.columns import Counter, List, Set |
6 | 6 |
|
7 | 7 | from cqlengine.connection import execute |
8 | | -from cqlengine.exceptions import CQLEngineException, ValidationError, TransactionException, LWTException |
| 8 | +from cqlengine.exceptions import CQLEngineException, ValidationError, LWTException |
9 | 9 | from cqlengine.functions import Token, BaseQueryFunction, QueryValue, UnicodeMixin |
10 | 10 |
|
11 | 11 | #CQL 3 reference: |
@@ -849,14 +849,8 @@ def _execute(self, q): |
849 | 849 | return self._batch.add_query(q) |
850 | 850 | else: |
851 | 851 | tmp = execute(q, consistency_level=self._consistency) |
852 | | - if self._if_not_exists: |
| 852 | + if self._if_not_exists or self._transaction: |
853 | 853 | check_applied(tmp) |
854 | | - if self._transaction and tmp[0].get('[applied]', True) is False: |
855 | | - tmp[0].pop('[applied]') |
856 | | - expected = ', '.join('{0}={1}'.format(t.field, t.value) for t in q.transactions) |
857 | | - actual = ', '.join('{0}={1}'.format(f, v) for f, v in tmp[0].items()) |
858 | | - message = 'Transaction statement failed: Expected: {0} Actual: {1}'.format(expected, actual) |
859 | | - raise TransactionException(message) |
860 | 854 | return tmp |
861 | 855 |
|
862 | 856 | def batch(self, batch_obj): |
@@ -966,7 +960,7 @@ def save(self): |
966 | 960 | if self.instance._has_counter or self.instance._can_update(): |
967 | 961 | return self.update() |
968 | 962 | else: |
969 | | - insert = InsertStatement(self.column_family_name, ttl=self._ttl, timestamp=self._timestamp, if_not_exists=self._if_not_exists, transactions=self._transaction) |
| 963 | + insert = InsertStatement(self.column_family_name, ttl=self._ttl, timestamp=self._timestamp, if_not_exists=self._if_not_exists) |
970 | 964 | for name, col in self.instance._columns.items(): |
971 | 965 | val = getattr(self.instance, name, None) |
972 | 966 | if col._val_is_null(val): |
|
0 commit comments