]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Disallow AliasedReturnsRows from execution
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2021 02:14:18 +0000 (22:14 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2021 03:35:53 +0000 (23:35 -0400)
commitac2ed15740629967e7fe004d3a7369ccf97aac46
tree51a3eac9240d84cfa55ed7a6a37f43ebe6920ec8
parent165c3a65dcb1ba3f42ecf2b5da7c298bdc259f9b
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
15 files changed:
doc/build/changelog/unreleased_14/6204.rst [new file with mode: 0644]
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/coercions.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/lambdas.py
lib/sqlalchemy/sql/roles.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/testing/suite/test_results.py
test/engine/test_execute.py
test/sql/test_compiler.py
test/sql/test_cte.py
test/sql/test_roles.py