summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-03-23 16:54:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-03-23 16:54:03 -0400
commit0a29071b16e1844b5e1d71aead0e8a1ae83b48d0 (patch)
tree095de6b2f2b495163e9c52a2b90ba2a1a24c5b59 /test
parent2d5b7a139f4d5e3cbf727c89a9b8389f4e12b26e (diff)
downloadsqlalchemy-0a29071b16e1844b5e1d71aead0e8a1ae83b48d0.tar.gz
- Further continuing on the common MySQL exception case of
a savepoint being cancelled first covered in :ticket:`2696`, the failure mode in which the :class:`.Session` is placed when a SAVEPOINT vanishes before rollback has been improved to allow the :class:`.Session` to still function outside of that savepoint. It is assumed that the savepoint operation failed and was cancelled. fixes #3680
Diffstat (limited to 'test')
-rw-r--r--test/orm/test_transaction.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py
index c1662c9d1..d912c669f 100644
--- a/test/orm/test_transaction.py
+++ b/test/orm/test_transaction.py
@@ -3,10 +3,10 @@ from sqlalchemy import (
testing, exc as sa_exc, event, String, Column, Table, select, func)
from sqlalchemy.testing import (
fixtures, engines, eq_, assert_raises, assert_raises_message,
- assert_warnings, mock, expect_warnings)
+ assert_warnings, mock, expect_warnings, is_, is_not_)
from sqlalchemy.orm import (
exc as orm_exc, Session, mapper, sessionmaker, create_session,
- relationship, attributes)
+ relationship, attributes, session as _session)
from sqlalchemy.testing.util import gc_collect
from test.orm._fixtures import FixtureTest
from sqlalchemy import inspect
@@ -1290,6 +1290,35 @@ class SavepointTest(_LocalFixture):
assert u1 in s
assert u1 not in s.deleted
+ @testing.requires.savepoints
+ def test_savepoint_lost_still_runs(self):
+ User = self.classes.User
+ s = self.session(bind=self.bind)
+ trans = s.begin_nested()
+ s.connection()
+ u1 = User(name='ed')
+ s.add(u1)
+
+ # kill off the transaction
+ nested_trans = trans._connections[self.bind][1]
+ nested_trans._do_commit()
+
+ is_(s.transaction, trans)
+ assert_raises(
+ sa_exc.DBAPIError,
+ s.rollback
+ )
+
+ assert u1 not in s.new
+
+ is_(trans._state, _session.CLOSED)
+ is_not_(s.transaction, trans)
+ is_(s.transaction._state, _session.ACTIVE)
+
+ is_(s.transaction.nested, False)
+
+ is_(s.transaction._parent, None)
+
class AccountingFlagsTest(_LocalFixture):
__backend__ = True