summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-11-18 11:49:00 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-11-18 11:53:33 -0500
commit7de0d1785335961ce0f723877ca7a8fd85b2c0ca (patch)
tree93aaacdfbcc497a87d21b9ab93b4cfd5a72a0631 /lib/sqlalchemy
parent68d3018ceefc33e42135ee208d6d492a47e695c7 (diff)
downloadsqlalchemy-7de0d1785335961ce0f723877ca7a8fd85b2c0ca.tar.gz
Disable single-inheritance critera on the outside of UNION
Fixed bug related to :ticket:`3177`, where a UNION or other set operation emitted by a :class:`.Query` would apply "single-inheritance" criteria to the outside of the union (also referencing the wrong selectable), even though this criteria is now expected to be already present on the inside subqueries. The single-inheritance criteria is now omitted once union() or another set operation is called against :class:`.Query` in the same way as :meth:`.Query.from_self`. Change-Id: I0fd1331c7ba85a758a1c15e06c271914f2c717f3 Fixes: #3856
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 139b61afb..340e71d25 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1607,6 +1607,11 @@ class Query(object):
else:
self._having = criterion
+ def _set_op(self, expr_fn, *q):
+ return self._from_selectable(
+ expr_fn(*([self] + list(q)))
+ )._set_enable_single_crit(False)
+
def union(self, *q):
"""Produce a UNION of this Query against one or more queries.
@@ -1644,9 +1649,7 @@ class Query(object):
its SELECT statement.
"""
-
- return self._from_selectable(
- expression.union(*([self] + list(q))))
+ return self._set_op(expression.union, *q)
def union_all(self, *q):
"""Produce a UNION ALL of this Query against one or more queries.
@@ -1655,9 +1658,7 @@ class Query(object):
that method for usage examples.
"""
- return self._from_selectable(
- expression.union_all(*([self] + list(q)))
- )
+ return self._set_op(expression.union_all, *q)
def intersect(self, *q):
"""Produce an INTERSECT of this Query against one or more queries.
@@ -1666,9 +1667,7 @@ class Query(object):
that method for usage examples.
"""
- return self._from_selectable(
- expression.intersect(*([self] + list(q)))
- )
+ return self._set_op(expression.intersect, *q)
def intersect_all(self, *q):
"""Produce an INTERSECT ALL of this Query against one or more queries.
@@ -1677,9 +1676,7 @@ class Query(object):
that method for usage examples.
"""
- return self._from_selectable(
- expression.intersect_all(*([self] + list(q)))
- )
+ return self._set_op(expression.intersect_all, *q)
def except_(self, *q):
"""Produce an EXCEPT of this Query against one or more queries.
@@ -1688,9 +1685,7 @@ class Query(object):
that method for usage examples.
"""
- return self._from_selectable(
- expression.except_(*([self] + list(q)))
- )
+ return self._set_op(expression.except_, *q)
def except_all(self, *q):
"""Produce an EXCEPT ALL of this Query against one or more queries.
@@ -1699,9 +1694,7 @@ class Query(object):
that method for usage examples.
"""
- return self._from_selectable(
- expression.except_all(*([self] + list(q)))
- )
+ return self._set_op(expression.except_all, *q)
def join(self, *props, **kwargs):
"""Create a SQL JOIN against this :class:`.Query` object's criterion
@@ -3447,7 +3440,6 @@ class Query(object):
subtypes are selected from the total results.
"""
-
for (ext_info, adapter) in set(self._mapper_adapter_map.values()):
if ext_info in self._join_entities:
continue