]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
establish explicit join transaction modes
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Dec 2022 17:48:08 +0000 (12:48 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Dec 2022 21:18:18 +0000 (16:18 -0500)
commit0f7ba068a91cbaa7233315d93d0d8624a6a7930f
tree8b6e724144a62c72a749b1ef070fb32d99e2e0dd
parent6eceb939744e000e627edeabe2da4694fa193eff
establish explicit join transaction modes

The behavior of "joining an external transaction into a Session" has been
revised and improved, allowing explicit control over how the
:class:`_orm.Session` will accommodate an incoming
:class:`_engine.Connection` that already has a transaction and possibly a
savepoint already established. The new parameter
:paramref:`_orm.Session.join_transaction_mode` includes a series of option
values which can accommodate the existing transaction in several ways, most
importantly allowing a :class:`_orm.Session` to operate in a fully
transactional style using savepoints exclusively, while leaving the
externally initiated transaction non-committed and active under all
circumstances, allowing test suites to rollback all changes that take place
within tests.

Additionally, revised the :meth:`_orm.Session.close` method to fully close
out savepoints that may still be present, which also allows the
"external transaction" recipe to proceed without warnings if the
:class:`_orm.Session` did not explicitly end its own SAVEPOINT
transactions.

Fixes: #9015
Change-Id: I31c22ee0fd9372fa0eddfe057e76544aee627107
doc/build/changelog/unreleased_20/9015.rst [new file with mode: 0644]
doc/build/changelog/whatsnew_20.rst
doc/build/orm/session_transaction.rst
lib/sqlalchemy/orm/session.py
test/orm/test_session.py
test/orm/test_transaction.py