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/util.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/util.py')
| -rw-r--r-- | lib/sqlalchemy/sql/util.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index fe83b163c..3c7f904de 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -364,23 +364,19 @@ def surface_selectables_only(clause): stack.append(elem.table) -def surface_column_elements(clause, include_scalar_selects=True): - """traverse and yield only outer-exposed column elements, such as would - be addressable in the WHERE clause of a SELECT if this element were - in the columns clause.""" +def extract_first_column_annotation(column, annotation_name): + filter_ = (FromGrouping, SelectBase) - filter_ = (FromGrouping,) - if not include_scalar_selects: - filter_ += (SelectBase,) - - stack = deque([clause]) + stack = deque([column]) while stack: elem = stack.popleft() - yield elem + if annotation_name in elem._annotations: + return elem._annotations[annotation_name] for sub in elem.get_children(): if isinstance(sub, filter_): continue stack.append(sub) + return None def selectables_overlap(left, right): |
