diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-11-11 12:57:32 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-11-11 12:57:32 -0500 |
| commit | 33c378f768c699f3590f168f6c3c86448239268c (patch) | |
| tree | 3f040fef0dd9cd03d5e5c4365ac67c27f31fd73f /lib/sqlalchemy | |
| parent | d51a36397e2449afccb9b70d3ec3d13990460124 (diff) | |
| download | sqlalchemy-33c378f768c699f3590f168f6c3c86448239268c.tar.gz | |
- Fixed bug where the "single table inheritance" criteria would be
added onto the end of a query in some inappropriate situations, such
as when querying from an exists() of a single-inheritance subclass.
fixes #3582
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/util.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 3b51b80ba..84fb04d80 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -3676,7 +3676,7 @@ class _ColumnEntity(_QueryEntity): self._from_entities = set(self.entities) else: all_elements = [ - elem for elem in visitors.iterate(column, {}) + elem for elem in sql_util.surface_column_elements(column) if 'parententity' in elem._annotations ] diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index cbd74faac..5def70444 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -203,6 +203,21 @@ def surface_selectables(clause): stack.append(elem.element) +def surface_column_elements(clause): + """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.""" + + stack = deque([clause]) + while stack: + elem = stack.popleft() + yield elem + for sub in elem.get_children(): + if isinstance(elem, FromGrouping): + continue + stack.append(sub) + + def selectables_overlap(left, right): """Return True if left/right have some overlapping selectable""" |
