From 21f208e66e6472b8db8cdfd7cd1102d71bb15733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sat, 29 Mar 2014 07:58:25 +0200 Subject: [PATCH] Fixed #22250 -- regression in gis compiler for non-concrete fields Thanks to gwahl@fusionbox.com for the report. --- django/contrib/gis/db/models/sql/compiler.py | 2 +- django/contrib/gis/tests/geoapp/tests.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py index 398d702d71..dc559f7fb3 100644 --- a/django/contrib/gis/db/models/sql/compiler.py +++ b/django/contrib/gis/db/models/sql/compiler.py @@ -124,7 +124,7 @@ class GeoSQLCompiler(compiler.SQLCompiler): seen = self.query.included_inherited_models.copy() if start_alias: seen[None] = start_alias - for field, model in opts.get_fields_with_model(): + for field, model in opts.get_concrete_fields_with_model(): if from_parent and model is not None and issubclass(from_parent, model): # Avoid loading data for already loaded parents. continue diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index 01ed519f28..8456ca1718 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -794,3 +794,12 @@ class GeoQuerySetTest(TestCase): self.assertEqual(True, union.equals_exact(u2, tol)) qs = City.objects.filter(name='NotACity') self.assertEqual(None, qs.unionagg(field_name='point')) + + def test_non_concrete_field(self): + pkfield = City._meta.get_field_by_name('id')[0] + orig_pkfield_col = pkfield.column + pkfield.column = None + try: + list(City.objects.all()) + finally: + pkfield.column = orig_pkfield_col