diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-27 17:32:10 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-30 10:10:58 -0400 |
commit | 6ddb62a8ba66b19afd41b967911ce5982250856e (patch) | |
tree | b98eba226618f2dff301366ac7e384f052feb69e /lib/sqlalchemy/sql/coercions.py | |
parent | 2c34d2503a17316cae3282192405b9b9d60df6fe (diff) | |
download | sqlalchemy-6ddb62a8ba66b19afd41b967911ce5982250856e.tar.gz |
Simplify _ColumnEntity, related
In the interests of making Query much more lightweight up front,
rework the calculations done at the top when the entities
are constructed to be much less inolved. Use the new
coercion system for _ColumnEntity and stop accepting
plain strings, this will need to emit a deprecation warning
in 1.3.x. Use annotations and other techniques to reduce
the decisionmaking and complexity of Query.
For the use case of subquery(), .statement, etc. we would like
to do minimal work in order to get the columns clause.
Change-Id: I7e459bbd3bb10ec71235f75ef4f3b0a969bec590
Diffstat (limited to 'lib/sqlalchemy/sql/coercions.py')
-rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index a7a856bba..95aee0468 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -57,7 +57,7 @@ def expect(role, element, **kw): else: resolved = element - if issubclass(resolved.__class__, impl._role_class): + if impl._role_class in resolved.__class__.__mro__: if impl._post_coercion: resolved = impl._post_coercion(resolved, **kw) return resolved @@ -102,13 +102,16 @@ class RoleImpl(object): def _resolve_for_clause_element(self, element, argname=None, **kw): original_element = element - is_clause_element = False + is_clause_element = hasattr(element, "__clause_element__") - while hasattr(element, "__clause_element__") and not isinstance( - element, (elements.ClauseElement, schema.SchemaItem) - ): - element = element.__clause_element__() - is_clause_element = True + if is_clause_element: + while not isinstance( + element, (elements.ClauseElement, schema.SchemaItem) + ): + try: + element = element.__clause_element__() + except AttributeError: + break if not is_clause_element: if self._use_inspection: |