Ticket #13357: django-pypy.diff

File django-pypy.diff, 5.9 KB (added by Alex Gaynor, 14 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 2c2bcd5..1d3a150 100644
    a b class BaseModelAdmin(object):  
    7373    readonly_fields = ()
    7474
    7575    def __init__(self):
    76         self.formfield_overrides = dict(FORMFIELD_FOR_DBFIELD_DEFAULTS, **self.formfield_overrides)
     76        overrides = FORMFIELD_FOR_DBFIELD_DEFAULTS.copy()
     77        overrides.update(self.formfield_overrides)
     78        self.formfield_overrides = overrides
    7779
    7880    def formfield_for_dbfield(self, db_field, **kwargs):
    7981        """
  • tests/modeltests/aggregation/models.py

    diff --git a/tests/modeltests/aggregation/models.py b/tests/modeltests/aggregation/models.py
    index e5f0f5d..74e43b8 100644
    a b u'The Definitive Guide to Django: Web Development Done Right'  
    191191
    192192# Calling values on a queryset that has annotations returns the output
    193193# as a dictionary
    194 >>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()
    195 [{'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]
     194>>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values()]
     195[[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]]
    196196
    197197>>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('pk', 'isbn', 'mean_age')
    198198[{'pk': 1, 'isbn': u'159059725', 'mean_age': 34.5}]
    u'The Definitive Guide to Django: Web Development Done Right'  
    203203
    204204# An empty values() call before annotating has the same effect as an
    205205# empty values() call after annotating
    206 >>> Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))
    207 [{'rating': 4.5, 'isbn': u'159059725', 'name': u'The Definitive Guide to Django: Web Development Done Right', 'pubdate': datetime.date(2007, 12, 6), 'price': Decimal("30..."), 'contact_id': 1, 'id': 1, 'publisher_id': 1, 'pages': 447, 'mean_age': 34.5}]
     206>>> [sorted(o.iteritems()) for o in Book.objects.filter(pk=1).values().annotate(mean_age=Avg('authors__age'))]
     207[[('contact_id', 1), ('id', 1), ('isbn', u'159059725'), ('mean_age', 34.5), ('name', u'The Definitive Guide to Django: Web Development Done Right'), ('pages', 447), ('price', Decimal("30...")), ('pubdate', datetime.date(2007, 12, 6)), ('publisher_id', 1), ('rating', 4.5)]]
    208208
    209209# Calling annotate() on a ValuesQuerySet annotates over the groups of
    210210# fields to be selected by the ValuesQuerySet.
  • tests/modeltests/expressions/models.py

    diff --git a/tests/modeltests/expressions/models.py b/tests/modeltests/expressions/models.py
    index 76006e1..f6292f5 100644
    a b FieldError: Joined field references are not permitted in this query  
    127127>>> acme.save()
    128128Traceback (most recent call last):
    129129...
    130 TypeError: int() argument must be a string or a number...
     130TypeError: ...
    131131
    132132"""}
  • tests/regressiontests/aggregation_regress/models.py

    diff --git a/tests/regressiontests/aggregation_regress/models.py b/tests/regressiontests/aggregation_regress/models.py
    index 7c51cd1..66a5ff7 100644
    a b FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta  
    174174{'number': 1132, 'select': 1132}
    175175
    176176# Regression for #10064: select_related() plays nice with aggregates
    177 >>> Book.objects.select_related('publisher').annotate(num_authors=Count('authors')).values()[0]
    178 {'rating': 4.0, 'isbn': u'013790395', 'name': u'Artificial Intelligence: A Modern Approach', 'pubdate': datetime.date(1995, 1, 15), 'price': Decimal("82.8..."), 'contact_id': 8, 'id': 5, 'num_authors': 2, 'publisher_id': 3, 'pages': 1132}
     177>>> sorted(Book.objects.select_related('publisher').annotate(num_authors=Count('authors')).values()[0].iteritems())
     178[('contact_id', 8), ('id', 5), ('isbn', u'013790395'), ('name', u'Artificial Intelligence: A Modern Approach'), ('num_authors', 2), ('pages', 1132), ('price', Decimal("82.8...")), ('pubdate', datetime.date(1995, 1, 15)), ('publisher_id', 3), ('rating', 4.0)]
    179179
    180180# Regression for #10010: exclude on an aggregate field is correctly negated
    181181>>> len(Book.objects.annotate(num_authors=Count('authors')))
    FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta  
    219219>>> Book.objects.filter(id__in=[]).aggregate(num_authors=Count('authors'), avg_authors=Avg('authors'), max_authors=Max('authors'), max_price=Max('price'), max_rating=Max('rating'))
    220220{'max_authors': None, 'max_rating': None, 'num_authors': 0, 'avg_authors': None, 'max_price': None}
    221221
    222 >>> Publisher.objects.filter(pk=5).annotate(num_authors=Count('book__authors'), avg_authors=Avg('book__authors'), max_authors=Max('book__authors'), max_price=Max('book__price'), max_rating=Max('book__rating')).values()
    223 [{'max_authors': None, 'name': u"Jonno's House of Books", 'num_awards': 0, 'max_price': None, 'num_authors': 0, 'max_rating': None, 'id': 5, 'avg_authors': None}]
     222>>> list(Publisher.objects.filter(pk=5).annotate(num_authors=Count('book__authors'), avg_authors=Avg('book__authors'), max_authors=Max('book__authors'), max_price=Max('book__price'), max_rating=Max('book__rating')).values()) == [{'max_authors': None, 'name': u"Jonno's House of Books", 'num_awards': 0, 'max_price': None, 'num_authors': 0, 'max_rating': None, 'id': 5, 'avg_authors': None}]
     223True
    224224
    225225# Regression for #10113 - Fields mentioned in order_by() must be included in the GROUP BY.
    226226# This only becomes a problem when the order_by introduces a new join.
Back to Top