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/coercions.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/coercions.py')
-rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index 35ac1a5ba..c00262fd5 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -824,11 +824,7 @@ class ReturnsRowsImpl(RoleImpl): __slots__ = () -class StatementImpl(_NoTextCoercion, RoleImpl): - __slots__ = () - - -class CoerceTextStatementImpl(_CoerceLiterals, RoleImpl): +class StatementImpl(_CoerceLiterals, RoleImpl): __slots__ = () def _implicit_coercions( @@ -837,7 +833,7 @@ class CoerceTextStatementImpl(_CoerceLiterals, RoleImpl): if resolved._is_lambda_element: return resolved else: - return super(CoerceTextStatementImpl, self)._implicit_coercions( + return super(StatementImpl, self)._implicit_coercions( original_element, resolved, argname=argname, **kw ) |