summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2017-03-15 17:12:03 -0400
committerGerrit Code Review <gerrit@awstats.zzzcomputing.com>2017-03-15 17:12:03 -0400
commitb5b6e9574854fd9784d7c26e2c585a3ff5ae4cb6 (patch)
tree4ba4e937c6c59512f7d7109350b8865db1b52ee7 /lib/sqlalchemy
parent7b056709c0f8a37744d18f37d40f94fa30c50c71 (diff)
parentb6a6ffa4c0e0911bb6c5e66b67da9789989c7699 (diff)
downloadsqlalchemy-b5b6e9574854fd9784d7c26e2c585a3ff5ae4cb6.tar.gz
Merge "Consult _select_from_entity in _adjust_for_single_inheritance"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 2fae36272..f6459de2c 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -3475,12 +3475,22 @@ class Query(object):
"""Apply single-table-inheritance filtering.
For all distinct single-table-inheritance mappers represented in
- the columns clause of this query, add criterion to the WHERE
+ the columns clause of this query, as well as the "select from entity",
+ add criterion to the WHERE
clause of the given QueryContext such that only the appropriate
subtypes are selected from the total results.
"""
- for (ext_info, adapter) in set(self._mapper_adapter_map.values()):
+
+ search = set(self._mapper_adapter_map.values())
+ if self._select_from_entity:
+ # based on the behavior in _set_select_from,
+ # when we have self._select_from_entity, we don't
+ # have _from_obj_alias.
+ # assert self._from_obj_alias is None
+ search = search.union([(self._select_from_entity, None)])
+
+ for (ext_info, adapter) in search:
if ext_info in self._join_entities:
continue
single_crit = ext_info.mapper._single_table_criterion