]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
implement autobegin=False option
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Oct 2022 21:01:43 +0000 (17:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Oct 2022 23:05:41 +0000 (19:05 -0400)
commit4580239b35642045c847c6faac8dd4fe304bb845
tree3558ab9d11852a289b69ee424fe6d5fc3fc89f0c
parentd4b8b41832267918e74c114c26def5b38d15e9e2
implement autobegin=False option

Added new parameter :paramref:`_orm.Session.autobegin`, which when set to
``False`` will prevent the :class:`_orm.Session` from beginning a
transaction implicitly. The :meth:`_orm.Session.begin` method must be
called explicitly first in order to proceed with operations, otherwise an
error is raised whenever any operation would otherwise have begun
automatically. This option can be used to create a "safe"
:class:`_orm.Session` that won't implicitly start new transactions.

As part of this change, also added a new status variable
:class:`_orm.SessionTransaction.origin` which may be useful for event
handling code to be aware of the origin of a particular
:class:`_orm.SessionTransaction`.

Fixes: #6928
Change-Id: I246f895c4a475bff352216e5bc74b6a25e6a4ae7
doc/build/changelog/unreleased_20/6928.rst [new file with mode: 0644]
doc/build/orm/session_api.rst
doc/build/orm/session_basics.rst
doc/build/orm/session_transaction.rst
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
test/orm/test_session.py
test/orm/test_transaction.py