summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-06-25 16:10:01 -0400
committermike bayer <mike_mp@zzzcomputing.com>2021-06-26 19:08:04 +0000
commit77e58046dc9222a4a869443cf30bc9ff39312f9d (patch)
treeea16beecd5222f509342259b63d076d1699c6700 /lib
parent84a68ac8820a2e1043f8317d42c5681c81cbd9d5 (diff)
downloadsqlalchemy-77e58046dc9222a4a869443cf30bc9ff39312f9d.tar.gz
set _render_for_subquery for legacy set ops
Adjusted :meth:`_orm.Query.union` and similar set operations to be correctly compatible with the new capabilities just added in :ticket:`6661`, with SQLAlchemy 1.4.19, such that the SELECT statements rendered as elements of the UNION or other set operation will include directly mapped columns that are mapped as deferred; this both fixes a regression involving unions with multiple levels of nesting that would produce a column mismatch, and also allows the :func:`_orm.undefer` option to be used at the top level of such a :class:`_orm.Query` without having to apply the option to each of the elements within the UNION. Fixes: #6678 Change-Id: Iba97ce7fd8a965499853256fd2eb7f61512db60f
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/query.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 7ba31fa7a..d8f4b4ea7 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -611,7 +611,9 @@ class Query(
def __clause_element__(self):
return (
- self.enable_eagerloads(False)
+ self._with_compile_options(
+ _enable_eagerloads=False, _render_for_subquery=True
+ )
.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
.statement
)
@@ -675,6 +677,10 @@ class Query(
"""
self._compile_options += {"_enable_eagerloads": value}
+ @_generative
+ def _with_compile_options(self, **opt):
+ self._compile_options += opt
+
@util.deprecated_20(
":meth:`_orm.Query.with_labels` and :meth:`_orm.Query.apply_labels`",
alternative="Use set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) "