Skip to content

Commit

Permalink
Fixed #16409 (again, this time for GeoDjango).
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ramiro committed Feb 11, 2012
1 parent 44452b1 commit d72d5ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/gis/db/models/sql/compiler.py
Expand Up @@ -37,7 +37,7 @@ def get_columns(self, with_aliases=False):
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:
Expand Down
6 changes: 6 additions & 0 deletions django/contrib/gis/tests/geoapp/test_regress.py
Expand Up @@ -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
Expand Down Expand Up @@ -58,3 +59,8 @@ def test05_empty_count(self):

# .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)

0 comments on commit d72d5ce

Please sign in to comment.