]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
restore legacy begin_nested()->root transaction behavior
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 2 May 2021 14:19:16 +0000 (10:19 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 2 May 2021 14:19:16 +0000 (10:19 -0400)
commitee7a82d71783bf71f3a95550624740e908d178a0
tree67a7af7e21ed8f1df7a1830e354058bf42b54929
parentbae435d44863e9c364dd9df8482c014ad7d56ee4
restore legacy begin_nested()->root transaction behavior

Restored a legacy transactional behavior that was inadvertently removed
from the :class:`_engine.Connection` as it was never tested as a known use
case in previous versions, where calling upon the
:meth:`_engine.Connection.begin_nested` method, when no transaction were
present, would not create a SAVEPOINT at all, and would instead only start
the outermost transaction alone, and return that :class:`.RootTransaction`
object, acting like the outermost transaction.   Committing the transaction
object returned by :meth:`_engine.Connection.begin_nested` would therefore
emit a real COMMIT on the database connection.

This behavior is not at all what the 2.0 style connection will do - in 2.0
style, calling :meth:`_future.Connection.begin_nested` will "autobegin" the
outer transaction, and then as instructed emit a SAVEPOINT, returning the
:class:`.NestedTransaction` object. The outer transaction is committed by
calling upon :meth:`_future.Connection.commit`, as is "commit-as-you-go"
style usage.

In non-"future" mode, while the old behavior is restored, it also
emits a 2.0 deprecation warning as this is a legacy behavior.

Additionally clarifies and reformats various engine-related
documentation, in particular future connection.begin() which
was a tire fire.

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