Ticket #11293: django_11414_filter_patch.diff

File django_11414_filter_patch.diff, 1.6 KB (added by shadfc, 15 years ago)

patch against 11414, fixes "simple" cases

  • django/db/models/sql/query.py

     
    15561556                entry.add((aggregate, lookup_type, value), AND)
    15571557                if negate:
    15581558                    entry.negate()
    1559                 self.having.add(entry, AND)
     1559                self.having.add(entry, connector)
    15601560                return
    15611561
    15621562        opts = self.get_meta()
  • tests/regressiontests/aggregation_regress/models.py

     
    318318...
    319319FieldError: Cannot compute Avg('mean_age'): 'mean_age' is an aggregate
    320320
     321# Regressions for #11293
     322>>> from django.db.models import Q,F
     323>>> Publisher.objects.annotate(rating_sum=Sum('book__rating'), book_count=Count('book')).filter( Q(rating_sum__gt=5.5) | Q(rating_sum__isnull=True)).order_by('pk')
     324[<Publisher: Apress>, <Publisher: Prentice Hall>, <Publisher: Jonno's House of Books>]
     325>>> Publisher.objects.annotate(rating_sum=Sum('book__rating'), book_count=Count('book')).filter( Q(pk__lt=F('book_count')) | Q(rating_sum=None), name__contains='Jonn' )
     326[<Publisher: Jonno's House of Books>]
     327>>> Publisher.objects.annotate(rating_sum=Sum('book__rating'), book_count=Count('book')).filter( Q(pk__lt=F('book_count')) | Q(rating_sum=None) ).order_by('pk')
     328[<Publisher: Apress>, <Publisher: Jonno's House of Books>]
     329
    321330"""
    322331}
    323332
Back to Top