Ticket #15624: aggregate_bug_quick_patch.diff

File aggregate_bug_quick_patch.diff, 869 bytes (added by marekw2143, 14 years ago)

That's a quick hack that should work, but there probably exist more elegant solution.

  • db/models/sql/query.py

     
    337337        # over the subquery instead.
    338338        if self.group_by is not None:
    339339            from django.db.models.sql.subqueries import AggregateQuery
     340
     341            old_mask = self.aggregate_select_mask
     342            self.set_aggregate_mask(None)
     343
    340344            query = AggregateQuery(self.model)
    341345
    342346            obj = self.clone()
     
    348352                    query.aggregate_select[alias] = aggregate
    349353                    del obj.aggregate_select[alias]
    350354
     355            self.set_aggregate_mask(old_mask)
     356            obj.set_aggregate_mask(old_mask)
     357
    351358            try:
    352359                query.add_subquery(obj, using)
    353360            except EmptyResultSet:
Back to Top