diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-05 22:14:18 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-05 23:35:53 -0400 |
commit | ac2ed15740629967e7fe004d3a7369ccf97aac46 (patch) | |
tree | 51a3eac9240d84cfa55ed7a6a37f43ebe6920ec8 /lib/sqlalchemy/sql/lambdas.py | |
parent | 165c3a65dcb1ba3f42ecf2b5da7c298bdc259f9b (diff) | |
download | sqlalchemy-ac2ed15740629967e7fe004d3a7369ccf97aac46.tar.gz |
Disallow AliasedReturnsRows from execution
Executing a :class:`_sql.Subquery` using :meth:`_engine.Connection.execute`
is deprecated and will emit a deprecation warning; this use case was an
oversight that should have been removed from 1.4. The operation will now
execute the underlying :class:`_sql.Select` object directly for backwards
compatibility. Similarly, the :class:`_sql.CTE` class is also not
appropriate for execution. In 1.3, attempting to execute a CTE would result
in an invalid "blank" SQL statement being executed; since this use case was
not working it now raises :class:`_exc.ObjectNotExecutableError`.
Previously, 1.4 was attempting to execute the CTE as a statement however it
was working only erratically.
The change also breaks out StatementRole from ReturnsRowsRole, as these
roles should not be in the same lineage (some statements don't return
rows, the whole class of ReturnsRows that are from clauses are
not statements). Consolidate StatementRole and
CoerceTextStatementRole as there's no usage difference between
these. Simplify some old tests that were trying to make
sure that "execution options" didn't transmit from a cte/subquery
out to a select; as cte/subuqery() aren't executable in any case
the options are removed.
Fixes: #6204
Change-Id: I62613b7ab418afdd22c409eae75659e3f52fb65f
Diffstat (limited to 'lib/sqlalchemy/sql/lambdas.py')
-rw-r--r-- | lib/sqlalchemy/sql/lambdas.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/lambdas.py b/lib/sqlalchemy/sql/lambdas.py index ebf576c8f..06db8f95e 100644 --- a/lib/sqlalchemy/sql/lambdas.py +++ b/lib/sqlalchemy/sql/lambdas.py @@ -100,7 +100,7 @@ def lambda_stmt( return StatementLambdaElement( lmb, - roles.CoerceTextStatementRole, + roles.StatementRole, LambdaOptions( enable_tracking=enable_tracking, track_on=track_on, @@ -155,9 +155,7 @@ class LambdaElement(elements.ClauseElement): self.tracker_key = (fn.__code__,) self.opts = opts - if apply_propagate_attrs is None and ( - role is roles.CoerceTextStatementRole - ): + if apply_propagate_attrs is None and (role is roles.StatementRole): apply_propagate_attrs = self rec = self._retrieve_tracker_rec(fn, apply_propagate_attrs, opts) @@ -493,10 +491,6 @@ class StatementLambdaElement(roles.AllowsLambdaRole, LambdaElement): return self._rec.expected_expr._effective_plugin_target @property - def _is_future(self): - return self._rec.expected_expr._is_future - - @property def _execution_options(self): return self._rec.expected_expr._execution_options |