diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-10-05 11:25:10 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-10-05 11:29:11 -0400 |
| commit | 1281e6e6c41ad3d7240fe50f4fecab4083b79975 (patch) | |
| tree | c34474735e097082259b8b9cb063e4a6b06d6b02 /lib/sqlalchemy/sql/util.py | |
| parent | 2c280791886756422a8103769cf131b0fe292ffe (diff) | |
| download | sqlalchemy-1281e6e6c41ad3d7240fe50f4fecab4083b79975.tar.gz | |
Don't include SelectBase when searching for surface column elements
Fixed bug where correlated select used against single-table inheritance
entity would fail to render correctly in the outer query, due to adjustment
for single inheritance discriminator criteria inappropriately re-applying
the criteria to the outer query.
Change-Id: I38df21f1392af1843e10119682fa0635d346e2a8
Fixes: #4103
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
| -rw-r--r-- | lib/sqlalchemy/sql/util.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 281d5f6a3..0c122949b 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -18,7 +18,7 @@ from collections import deque from .elements import BindParameter, ColumnClause, ColumnElement, \ Null, UnaryExpression, literal_column, Label, _label_reference, \ _textual_label_reference -from .selectable import ScalarSelect, Join, FromClause, FromGrouping +from .selectable import SelectBase, ScalarSelect, Join, FromClause, FromGrouping from .schema import Column join_condition = util.langhelpers.public_factory( @@ -235,17 +235,21 @@ def surface_selectables(clause): stack.append(elem.element) -def surface_column_elements(clause): +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.""" + filter_ = (FromGrouping, ) + if not include_scalar_selects: + filter_ += (SelectBase, ) + stack = deque([clause]) while stack: elem = stack.popleft() yield elem for sub in elem.get_children(): - if isinstance(sub, FromGrouping): + if isinstance(sub, filter_): continue stack.append(sub) |
