summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2012-02-11 13:50:27 +0000
committerRamiro Morales <cramm0@gmail.com>2012-02-11 13:50:27 +0000
commitd72d5ce8274992ce01e39f866a7a250bc459eefe (patch)
treef4a011260d045c85068889af2c449ac3a662bfab
parent44452b11eb964e34e62ce8d5feab1c45d29c2e58 (diff)
Fixed #16409 (again, this time for GeoDjango).
Thanks Aymeric Augustin for the regression test and Petr Gorodechnyj for the patch. Refs r16522. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17506 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/gis/db/models/sql/compiler.py2
-rw-r--r--django/contrib/gis/tests/geoapp/test_regress.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py
index 9a4ea6a942..a7c3fbc406 100644
--- a/django/contrib/gis/db/models/sql/compiler.py
+++ b/django/contrib/gis/db/models/sql/compiler.py
@@ -37,7 +37,7 @@ class GeoSQLCompiler(compiler.SQLCompiler):
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:
diff --git a/django/contrib/gis/tests/geoapp/test_regress.py b/django/contrib/gis/tests/geoapp/test_regress.py
index 2cf4654386..1e68440286 100644
--- a/django/contrib/gis/tests/geoapp/test_regress.py
+++ b/django/contrib/gis/tests/geoapp/test_regress.py
@@ -4,6 +4,7 @@ from datetime import datetime
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 @@ class GeoRegressionTests(TestCase):
# .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)