diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-15 18:24:56 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-01-15 20:14:34 -0500 |
| commit | c5b4af959e13f8214121f62f322c668bb178d41f (patch) | |
| tree | 7369dfbf35c7005ec2cfcf965f77a42d4ed98671 /lib/sqlalchemy/engine/base.py | |
| parent | 5be3c030b321ecc342bf4cd84cbb0838efacd155 (diff) | |
| download | sqlalchemy-c5b4af959e13f8214121f62f322c668bb178d41f.tar.gz | |
Guard against re-entrant autobegin in Core, ORM
Fixed bug in "future" version of :class:`.Engine` where emitting SQL during
the :meth:`.EngineEvents.do_begin` event hook would cause a re-entrant
condition due to autobegin, including the recipe documented for SQLite to
allow for savepoints and serializable isolation support.
Fixed issue in new :class:`_orm.Session` similar to that of the
:class:`_engine.Connection` where the new "autobegin" logic could be
tripped into a re-entrant state if SQL were executed within the
:meth:`.SessionEvents.after_transaction_create` event hook.
Also repair the new "testing_engine" pytest fixture to
set up for "future" engine appropriately, which wasn't working
leading to the test_execute.py tests not using the future
engine since recent f1e96cb0874927a475d0c11139.
Fixes: #5845
Change-Id: Ib2432d8c8bd753e24be60720ec47affb2df15a4a
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 72d66b7c8..31bf885db 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -813,10 +813,11 @@ class Connection(Connectable): if self._echo: self.engine.logger.info("BEGIN (implicit)") + self.__in_begin = True + if self._has_events or self.engine._has_events: self.dispatch.begin(self) - self.__in_begin = True try: self.engine.dialect.do_begin(self.connection) except BaseException as e: |
