diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index b0463b7..56e350f 100644
a
|
b
|
class CursorWrapper(object):
|
16 | 16 | self.cursor = cursor |
17 | 17 | self.db = db |
18 | 18 | |
19 | | def __getattr__(self, attr): |
| 19 | def _set_dirty(self): |
20 | 20 | if self.db.is_managed(): |
21 | 21 | self.db.set_dirty() |
| 22 | |
| 23 | def __getattr__(self, attr): |
| 24 | self._set_dirty() |
22 | 25 | if attr in self.__dict__: |
23 | 26 | return self.__dict__[attr] |
24 | 27 | else: |
… |
… |
class CursorWrapper(object):
|
31 | 34 | class CursorDebugWrapper(CursorWrapper): |
32 | 35 | |
33 | 36 | def execute(self, sql, params=()): |
| 37 | self._set_dirty() |
34 | 38 | start = time() |
35 | 39 | try: |
36 | 40 | return self.cursor.execute(sql, params) |
… |
… |
class CursorDebugWrapper(CursorWrapper):
|
47 | 51 | ) |
48 | 52 | |
49 | 53 | def executemany(self, sql, param_list): |
| 54 | self._set_dirty() |
50 | 55 | start = time() |
51 | 56 | try: |
52 | 57 | return self.cursor.executemany(sql, param_list) |
diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
index 22f1b0f..5907c3a 100644
a
|
b
|
|
1 | | from __future__ import absolute_import |
| 1 | from __future__ import absolute_import, with_statement |
2 | 2 | |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | 4 | from django.db import connection, transaction |
5 | 5 | from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError |
| 6 | from django.db.utils import DatabaseError |
6 | 7 | from django.test import TransactionTestCase, skipUnlessDBFeature |
| 8 | from django.test.utils import override_settings |
7 | 9 | from django.utils.unittest import skipIf |
8 | 10 | |
9 | 11 | from .models import Mod, M2mA, M2mB |
… |
… |
class TestTransactionClosing(TransactionTestCase):
|
166 | 168 | except: |
167 | 169 | self.fail("A transaction consisting of a failed operation was not closed.") |
168 | 170 | |
| 171 | # Same test with DebugCursor |
| 172 | with override_settings(DEBUG=True): |
| 173 | self.assertRaises(Exception, create_system_user) |
| 174 | try: |
| 175 | self.assertEqual(User.objects.count(), 1) |
| 176 | except DatabaseError: |
| 177 | self.fail("A transaction consisting of a failed operation was not closed.") |
| 178 | |
169 | 179 | |
170 | 180 | class TestManyToManyAddTransaction(TransactionTestCase): |
171 | 181 | def test_manyrelated_add_commit(self): |