Changes between Version 4 and Version 5 of Ticket #33050


Ignore:
Timestamp:
Aug 24, 2021, 12:04:43 PM (3 years ago)
Author:
Sunkyue
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33050 – Description

    v4 v5  
    4545}}}
    4646
     47reproduced on on 3.2.5/3.2.6
     48
     49
    4750suggested fix:
    4851on django.db.models.sql.query.py -> Query.get_aggregation, from
     
    5962                combined_query.select_related = False
    6063            inner_query.set_annotation_mask(self.annotation_select)
    61 
    6264}}}
    6365can solve the problem I think.
     
    7072
    7173def get_aggregation(self, using, added_aggregate_names):
    72     original_select_related_values = {}
    73     for combined_query in self.combined_queries:
    74         original_select_related_values[combined_query] = combined_query.select_related
     74    cloned_self = self.clone()
     75    for combined_query in cloned_self.combined_queries:
    7576        combined_query.select_related = False
    76     result = old_get_aggregation(self, using, added_aggregate_names)
    77     for combined_query in self.combined_queries:
    78         combined_query.select_related = original_select_related_values[combined_query]
    79     return result
     77    return old_get_aggregation(cloned_self, using, added_aggregate_names)
    8078
    8179Query.get_aggregation = get_aggregation
    8280}}}
    83 
    84 reproduced on on 3.2.5/3.2.6
Back to Top