Ticket #11789: 11789.diff

File 11789.diff, 1.1 KB (added by noah, 15 years ago)

A patch for this ticket

  • django/db/models/query.py

     
    11051105        Don't update anything.
    11061106        """
    11071107        return 0
     1108   
     1109    def aggregate(self, *args, **kwargs):
     1110        """
     1111        Returns a dict mapping the aggregate names to None
     1112        """
     1113        for arg in args:
     1114            kwargs[arg.default_alias] = arg
     1115        return dict([(key, None) for key in kwargs])
    11081116
    11091117    # EmptyQuerySet is always an empty result in where-clauses (and similar
    11101118    # situations).
  • tests/regressiontests/aggregation_regress/models.py

     
    318318...
    319319FieldError: Cannot compute Avg('mean_age'): 'mean_age' is an aggregate
    320320
     321# Regression for 11789 - Aggregates ignore none()
     322>>> Author.objects.none().aggregate(Avg('age'))
     323{'age__avg': None}
     324
    321325"""
    322326}
    323327
Back to Top