]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Run trans.close() at end of block if transaction already inactive
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 29 Mar 2021 20:40:16 +0000 (16:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Mar 2021 14:00:40 +0000 (10:00 -0400)
commitbd8b269a34153c29c7f05e4acacccc6b07b47fb5
treefde34fdd40e4f99e02b9ecb1adb95861d698156d
parent2c2e01a0c6d0847f5648fd0120c8fa0bd5f6268f
Run trans.close() at end of block if transaction already inactive

Modified the context manager used by :class:`_engine.Transaction` so that
an "already detached" warning is not emitted by the ending of the context
manager itself, if the transaction were already manually rolled back inside
the block. This applies to regular transactions, savepoint transactions,
and legacy "marker" transactions. A warning is still emitted if the
``.rollback()`` method is called explicitly more than once.

Fixes: #6155
Change-Id: Ib9f9d803bf377ec843d4a8a09da8ebef4b441665
doc/build/changelog/unreleased_14/6155.rst [new file with mode: 0644]
lib/sqlalchemy/engine/base.py
test/engine/test_transaction.py