From 038ee979985c5585287c5636bbfde607082f5130 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 14 Jan 2021 23:01:13 -0500 Subject: allow Executable to be accepted by Session.execute() Fixed an issue where the API to create a custom executable SQL construct using the ``sqlalchemy.ext.compiles`` extension according to the documentation that's been up for many years would no longer function if only ``Executable, ClauseElement`` were used as the base classes, additional classes were needed if wanting to use :meth:`_orm.Session.execute`. This has been resolved so that those extra classes aren't needed. Change-Id: I99b8acd88515c2a52842d62974199121e64c0381 --- lib/sqlalchemy/sql/base.py | 2 +- lib/sqlalchemy/sql/elements.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index a1426b628..550111020 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -729,7 +729,7 @@ class ExecutableOption(HasCopyInternals, HasCacheKey): return c -class Executable(Generative): +class Executable(roles.CoerceTextStatementRole, Generative): """Mark a :class:`_expression.ClauseElement` as supporting execution. :class:`.Executable` is a superclass for all "statement" types diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index d3c767b5d..5ea3526ea 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1502,7 +1502,6 @@ class TextClause( roles.OrderByRole, roles.FromClauseRole, roles.SelectStatementRole, - roles.CoerceTextStatementRole, roles.BinaryElementRole, roles.InElementRole, Executable, -- cgit v1.2.1