File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -254,15 +254,15 @@ def pre_sql_setup(self, with_col_aliases=False):
254254 all_replacements .update (replacements )
255255 pipeline = self ._build_aggregation_pipeline (ids , group )
256256 if self .having :
257- pipeline .append (
258- {
259- "$match" : {
260- "$expr" : self .having .replace_expressions (all_replacements ).as_mql (
261- self , self .connection
262- )
263- }
264- }
257+ having = self .having .replace_expressions (all_replacements ).as_mql (
258+ self , self .connection
265259 )
260+ # Add having subqueries.
261+ for query in self .subqueries or ():
262+ pipeline .extend (query .get_pipeline ())
263+ # Clean added subqueries.
264+ self .subqueries = None
265+ pipeline .append ({"$match" : {"$expr" : having }})
266266 self .aggregation_pipeline = pipeline
267267 self .annotations = {
268268 target : expr .replace_expressions (all_replacements )
You can’t perform that action at this time.
0 commit comments