Ticket #15624: aggregate_bug_quick_patch2.diff
File aggregate_bug_quick_patch2.diff, 1.4 KB (added by , 13 years ago) |
---|
-
db/models/sql/query.py
333 333 # Return value depends on the type of the field being processed. 334 334 return self.convert_values(value, aggregate.field, connection) 335 335 336 def disable_select_mask(self): 337 self.old_mask = self.aggregate_select_mask.copy() 338 self._aggregate_select_cache = None 339 self.aggregate_select_mask = None 340 341 def restore_select_mask(self): 342 self.aggregate_select_mask = self.old_mask 343 self._aggregate_select_cache = None 344 336 345 def get_aggregation(self, using): 337 346 """ 338 347 Returns the dictionary with the values of the existing aggregations. … … 344 353 # information but retrieves only the first row. Aggregate 345 354 # over the subquery instead. 346 355 if self.group_by is not None: 356 self.disable_select_mask() 357 347 358 from django.db.models.sql.subqueries import AggregateQuery 348 359 query = AggregateQuery(self.model) 349 360 … … 356 367 query.aggregate_select[alias] = aggregate 357 368 del obj.aggregate_select[alias] 358 369 370 self.restore_select_mask() 371 359 372 try: 360 373 query.add_subquery(obj, using) 361 374 except EmptyResultSet: