Ticket #10670: aggregation-copy.2.diff

File aggregation-copy.2.diff, 1.7 KB (added by Alex Gaynor, 16 years ago)
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index 0583386..2ce9e29 100644
    a b class BaseQuery(object):  
    196196        obj.distinct = self.distinct
    197197        obj.select_related = self.select_related
    198198        obj.related_select_cols = []
    199         obj.aggregates = self.aggregates.copy()
     199        obj.aggregates = deepcopy(self.aggregates)
    200200        if self.aggregate_select_mask is None:
    201201            obj.aggregate_select_mask = None
    202202        else:
    def add_to_dict(data, key, value):  
    23682368        data[key].add(value)
    23692369    else:
    23702370        data[key] = set([value])
    2371 
  • tests/regressiontests/aggregation_regress/models.py

    diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py
    index 275ea07..2dfa181 100644
    a b FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta  
    259259>>> Book.objects.annotate(Count('publisher')).values('publisher').count()
    2602606
    261261
     262>>> publishers = Publisher.objects.filter(id__in=(1,2))
     263>>> publishers
     264[<Publisher: Apress>, <Publisher: Sams>]
     265
     266>>> publishers = publishers.annotate(n_books=models.Count('book'))
     267>>> publishers[0].n_books
     2682
     269
     270>>> publishers
     271[<Publisher: Apress>, <Publisher: Sams>]
     272
     273>>> books = Book.objects.filter(publisher__in=publishers)
     274>>> books
     275[<Book: Practical Django Projects>, <Book: Sams Teach Yourself Django in 24 Hours>, <Book: The Definitive Guide to Django: Web Development Done Right>]
     276
     277>>> publishers
     278[<Publisher: Apress>, <Publisher: Sams>]
    262279"""
    263280}
    264281
    if settings.DATABASE_ENGINE != 'sqlite3':  
    307324
    308325
    309326"""
    310 
Back to Top