Ticket #13357: django-pypy.diff
File django-pypy.diff, 5.9 KB (added by , 15 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): 73 73 readonly_fields = () 74 74 75 75 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 77 79 78 80 def formfield_for_dbfield(self, db_field, **kwargs): 79 81 """ -
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' 191 191 192 192 # Calling values on a queryset that has annotations returns the output 193 193 # 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)]] 196 196 197 197 >>> Book.objects.filter(pk=1).annotate(mean_age=Avg('authors__age')).values('pk', 'isbn', 'mean_age') 198 198 [{'pk': 1, 'isbn': u'159059725', 'mean_age': 34.5}] … … u'The Definitive Guide to Django: Web Development Done Right' 203 203 204 204 # An empty values() call before annotating has the same effect as an 205 205 # 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)]] 208 208 209 209 # Calling annotate() on a ValuesQuerySet annotates over the groups of 210 210 # 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 127 127 >>> acme.save() 128 128 Traceback (most recent call last): 129 129 ... 130 TypeError: int() argument must be a string or a number...130 TypeError: ... 131 131 132 132 """} -
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 174 174 {'number': 1132, 'select': 1132} 175 175 176 176 # 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)] 179 179 180 180 # Regression for #10010: exclude on an aggregate field is correctly negated 181 181 >>> len(Book.objects.annotate(num_authors=Count('authors'))) … … FieldError: Cannot resolve keyword 'foo' into field. Choices are: authors, conta 219 219 >>> 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')) 220 220 {'max_authors': None, 'max_rating': None, 'num_authors': 0, 'avg_authors': None, 'max_price': None} 221 221 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}] 223 True 224 224 225 225 # Regression for #10113 - Fields mentioned in order_by() must be included in the GROUP BY. 226 226 # This only becomes a problem when the order_by introduces a new join.