diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-11 15:33:22 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-14 09:38:28 -0500 |
| commit | 628db9581c5bd43c01cbfcc16753477f206de431 (patch) | |
| tree | 709fc36121fe5c41faa73f5813ddcc8daca22d04 /lib/sqlalchemy | |
| parent | 8e9e473dcb76b57a7f0eaa476481cb66a258ea69 (diff) | |
| download | sqlalchemy-628db9581c5bd43c01cbfcc16753477f206de431.tar.gz | |
Emit 2.0 deprecation warning for sub-transactions
The nesting pattern will be removed in 2.0, so the use of the
MarkerTransaction should emit a 2.0 deprecation warning
unconditionally.
Change-Id: I96aed22c4e5db9b59e9b28a7f2d1283cd99a9cb6
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 028af9fbb..d36cf30e9 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -489,6 +489,7 @@ class Connection(Connectable): code="8s2b", ) else: + assert not self._is_future raise exc.PendingRollbackError( "This connection is on an inactive %stransaction. " "Please rollback() fully before proceeding." @@ -2190,6 +2191,15 @@ class MarkerTransaction(Transaction): "Please issue a rollback first." ) + assert not connection._is_future + util.warn_deprecated_20( + "Calling .begin() when a transaction is already begun, creating " + "a 'sub' transaction, is deprecated " + "and will be removed in 2.0. See the documentation section " + "'Migrating from the nesting pattern' for background on how " + "to migrate from this pattern." + ) + self.connection = connection if connection._nested_transaction is not None: self._transaction = connection._nested_transaction |
