| 65 | my current monkey-patching code is, |
| 66 | {{{ |
| 67 | from django.db.models.sql.query import Query |
| 68 | |
| 69 | old_get_aggregation = Query.get_aggregation |
| 70 | |
| 71 | def 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 |
| 75 | 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 |
| 80 | |
| 81 | Query.get_aggregation = get_aggregation |
| 82 | }}} |
| 83 | |