Author: Alex
Date: 2009-11-23 10:44:38 -0600 (Mon, 23 Nov 2009)
New Revision: 11773

Modified:
   
django/branches/soc2009/multidb/tests/regressiontests/aggregation_regress/models.py
Log:
[soc2009/multidb] Cleaned up check in aggregation_regress to remove the 
assumption that the only objects in __dict__ are field attributes.  Patch from 
Russell Keith-Magee.

Modified: 
django/branches/soc2009/multidb/tests/regressiontests/aggregation_regress/models.py
===================================================================
--- 
django/branches/soc2009/multidb/tests/regressiontests/aggregation_regress/models.py
 2009-11-23 16:44:30 UTC (rev 11772)
+++ 
django/branches/soc2009/multidb/tests/regressiontests/aggregation_regress/models.py
 2009-11-23 16:44:38 UTC (rev 11773)
@@ -97,19 +97,19 @@
 {'pages__sum': 3703}
 
 # Annotations get combined with extra select clauses
->>> 
sorted(Book.objects.all().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).get(pk=2).__dict__.items())
+>>> sorted((k,v) for k,v in 
Book.objects.all().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).get(pk=2).__dict__.items() if k != '_state')
 [('contact_id', 3), ('id', 2), ('isbn', u'067232959'), ('manufacture_cost', 
...11.545...), ('mean_auth_age', 45.0), ('name', u'Sams Teach Yourself Django 
in 24 Hours'), ('pages', 528), ('price', Decimal("23.09")), ('pubdate', 
datetime.date(2008, 3, 3)), ('publisher_id', 2), ('rating', 3.0)]
 
 # Order of the annotate/extra in the query doesn't matter
->>> sorted(Book.objects.all().extra(select={'manufacture_cost' : 'price * 
.5'}).annotate(mean_auth_age=Avg('authors__age')).get(pk=2).__dict__.items())
+>>> sorted((k,v) for k,v in 
Book.objects.all().extra(select={'manufacture_cost' : 'price * 
.5'}).annotate(mean_auth_age=Avg('authors__age')).get(pk=2).__dict__.items()if 
k != '_state')
 [('contact_id', 3), ('id', 2), ('isbn', u'067232959'), ('manufacture_cost', 
...11.545...), ('mean_auth_age', 45.0), ('name', u'Sams Teach Yourself Django 
in 24 Hours'), ('pages', 528), ('price', Decimal("23.09")), ('pubdate', 
datetime.date(2008, 3, 3)), ('publisher_id', 2), ('rating', 3.0)]
 
 # Values queries can be combined with annotate and extra
->>> 
sorted(Book.objects.all().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).values().get(pk=2).items())
+>>> sorted((k,v) for k,v in 
Book.objects.all().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).values().get(pk=2).items()if k != '_state')
 [('contact_id', 3), ('id', 2), ('isbn', u'067232959'), ('manufacture_cost', 
...11.545...), ('mean_auth_age', 45.0), ('name', u'Sams Teach Yourself Django 
in 24 Hours'), ('pages', 528), ('price', Decimal("23.09")), ('pubdate', 
datetime.date(2008, 3, 3)), ('publisher_id', 2), ('rating', 3.0)]
 
 # The order of the (empty) values, annotate and extra clauses doesn't matter
->>> 
sorted(Book.objects.all().values().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).get(pk=2).items())
+>>> sorted((k,v) for k,v in 
Book.objects.all().values().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost'
 : 'price * .5'}).get(pk=2).items()if k != '_state')
 [('contact_id', 3), ('id', 2), ('isbn', u'067232959'), ('manufacture_cost', 
...11.545...), ('mean_auth_age', 45.0), ('name', u'Sams Teach Yourself Django 
in 24 Hours'), ('pages', 528), ('price', Decimal("23.09")), ('pubdate', 
datetime.date(2008, 3, 3)), ('publisher_id', 2), ('rating', 3.0)]
 
 # If the annotation precedes the values clause, it won't be included

--

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=.


Reply via email to