We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aac7ed9 commit b7f4b5eCopy full SHA for b7f4b5e
django_cte/cte.py
@@ -153,6 +153,17 @@ def as_manager(cls):
153
as_manager.queryset_only = True
154
as_manager = classmethod(as_manager)
155
156
+ def _combinator_query(self, combinator, *other_qs, all=False):
157
+ clone = super(CTEQuerySet, self)._combinator_query(combinator, *other_qs, all=False)
158
+ if clone.query.combinator:
159
+ # Move CTE onto parent query, we can modify as they are cloned by super
160
+ sub_cte = []
161
+ for query in clone.query.combined_queries:
162
+ sub_cte.extend(query._with_ctes)
163
+ query._with_ctes=[]
164
+ clone.query._with_ctes = sub_cte
165
+ return clone
166
+
167
168
class CTEManager(Manager.from_queryset(CTEQuerySet)):
169
"""Manager for models that perform CTE queries"""
0 commit comments