From f07e050c9ce4afdeb9c0c136dbcc547f7e5ac7b8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 29 Apr 2019 23:26:36 -0400 Subject: Implement new ClauseElement role and coercion system A major refactoring of all the functions handle all detection of Core argument types as well as perform coercions into a new class hierarchy based on "roles", each of which identify a syntactical location within a SQL statement. In contrast to the ClauseElement hierarchy that identifies "what" each object is syntactically, the SQLRole hierarchy identifies the "where does it go" of each object syntactically. From this we define a consistent type checking and coercion system that establishes well defined behviors. This is a breakout of the patch that is reorganizing select() constructs to no longer be in the FromClause hierarchy. Also includes a rename of as_scalar() into scalar_subquery(); deprecates automatic coercion to scalar_subquery(). Partially-fixes: #4617 Change-Id: I26f1e78898693c6b99ef7ea2f4e7dfd0e8e1a1bd --- lib/sqlalchemy/sql/base.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/sql/base.py') diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index c5e5fd8a1..9df0c932f 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -17,6 +17,9 @@ from .visitors import ClauseVisitor from .. import exc from .. import util +coercions = None # type: types.ModuleType +elements = None # type: types.ModuleType +type_api = None # type: types.ModuleType PARSE_AUTOCOMMIT = util.symbol("PARSE_AUTOCOMMIT") NO_ARG = util.symbol("NO_ARG") @@ -589,8 +592,7 @@ class ColumnCollection(util.OrderedProperties): __hash__ = None - @util.dependencies("sqlalchemy.sql.elements") - def __eq__(self, elements, other): + def __eq__(self, other): l = [] for c in getattr(other, "_all_columns", other): for local in self._all_columns: @@ -636,8 +638,7 @@ class ColumnSet(util.ordered_column_set): def __add__(self, other): return list(self) + list(other) - @util.dependencies("sqlalchemy.sql.elements") - def __eq__(self, elements, other): + def __eq__(self, other): l = [] for c in other: for local in self: -- cgit v1.2.1