diff options
| author | Mark Young <marky1991@gmail.com> | 2016-11-23 08:42:19 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-11-23 08:42:19 -0500 |
| commit | 2742901ac210361bc2c4b662870d35a1be5a142c (patch) | |
| tree | 4db10c9ec755898cbe25969ed4763aff4347d5e6 /tests | |
| parent | b5ef90192fa4e1ebcf8c5d4abacb1caaefdc2008 (diff) | |
Fixed #27504 -- Allowed using the ORM after an error and rollback when autocommit is off.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/transactions/tests.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py index dcfd30fcaa..b3fdc7f915 100644 --- a/tests/transactions/tests.py +++ b/tests/transactions/tests.py @@ -443,8 +443,28 @@ class AtomicMiscTests(TransactionTestCase): # This is expected to fail because the savepoint no longer exists. connection.savepoint_rollback(sid) - @skipIf(connection.features.autocommits_when_autocommit_is_off, - "This test requires a non-autocommit mode that doesn't autocommit.") + +@skipIf( + connection.features.autocommits_when_autocommit_is_off, + "This test requires a non-autocommit mode that doesn't autocommit." +) +class NonAutocommitTests(TransactionTestCase): + + available_apps = [] + + def test_orm_query_after_error_and_rollback(self): + """ + ORM queries are allowed after an error and a rollback in non-autocommit + mode (#27504). + """ + transaction.set_autocommit(False) + r1 = Reporter.objects.create(first_name='Archibald', last_name='Haddock') + r2 = Reporter(first_name='Cuthbert', last_name='Calculus', id=r1.id) + with self.assertRaises(IntegrityError): + r2.save(force_insert=True) + transaction.rollback() + Reporter.objects.last() + def test_orm_query_without_autocommit(self): """#24921 -- ORM queries must be possible after set_autocommit(False).""" transaction.set_autocommit(False) |
