Author: ramiro
Date: 2012-02-11 05:50:27 -0800 (Sat, 11 Feb 2012)
New Revision: 17506

Modified:
   django/trunk/django/contrib/gis/db/models/sql/compiler.py
   django/trunk/django/contrib/gis/tests/geoapp/test_regress.py
Log:
Fixed #16409 (again, this time for GeoDjango).

Thanks Aymeric Augustin for the regression test and Petr Gorodechnyj for
the patch.

Refs r16522.

Modified: django/trunk/django/contrib/gis/db/models/sql/compiler.py
===================================================================
--- django/trunk/django/contrib/gis/db/models/sql/compiler.py   2012-02-11 
12:47:58 UTC (rev 17505)
+++ django/trunk/django/contrib/gis/db/models/sql/compiler.py   2012-02-11 
13:50:27 UTC (rev 17506)
@@ -37,7 +37,7 @@
                 if isinstance(col, (list, tuple)):
                     alias, column = col
                     table = self.query.alias_map[alias][TABLE_NAME]
-                    if table in only_load and col not in only_load[table]:
+                    if table in only_load and column not in only_load[table]:
                         continue
                     r = self.get_field_select(field, alias, column)
                     if with_aliases:

Modified: django/trunk/django/contrib/gis/tests/geoapp/test_regress.py
===================================================================
--- django/trunk/django/contrib/gis/tests/geoapp/test_regress.py        
2012-02-11 12:47:58 UTC (rev 17505)
+++ django/trunk/django/contrib/gis/tests/geoapp/test_regress.py        
2012-02-11 13:50:27 UTC (rev 17506)
@@ -4,6 +4,7 @@
 
 from django.contrib.gis.tests.utils import no_mysql, no_spatialite
 from django.contrib.gis.shortcuts import render_to_kmz
+from django.db.models import Count
 from django.test import TestCase
 
 from .models import City, PennsylvaniaCity, State
@@ -58,3 +59,8 @@
 
          # .count() should not throw TypeError in __eq__
          self.assertEqual(cities_within_state.count(), 1)
+
+    def test06_defer_or_only_with_annotate(self):
+        "Regression for #16409 - make sure defer() and only() work with 
annotate()"
+        
self.assertIsInstance(list(City.objects.annotate(Count('point')).defer('name')),
 list)
+        
self.assertIsInstance(list(City.objects.annotate(Count('point')).only('name')), 
list)

-- 
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=en.

Reply via email to