Skip to content

Commit

Permalink
[1.7.x] Fixed #22250 -- regression in gis compiler for non-concrete f…
Browse files Browse the repository at this point in the history
…ields

Thanks to gwahl@fusionbox.com for the report.

Backport of 21f208e from master
  • Loading branch information
akaariai committed Mar 29, 2014
1 parent c9014a9 commit a6a0800
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/gis/db/models/sql/compiler.py
Expand Up @@ -124,7 +124,7 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
seen = self.query.included_inherited_models.copy() seen = self.query.included_inherited_models.copy()
if start_alias: if start_alias:
seen[None] = 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): if from_parent and model is not None and issubclass(from_parent, model):
# Avoid loading data for already loaded parents. # Avoid loading data for already loaded parents.
continue continue
Expand Down
9 changes: 9 additions & 0 deletions django/contrib/gis/tests/geoapp/tests.py
Expand Up @@ -794,3 +794,12 @@ def test_unionagg(self):
self.assertEqual(True, union.equals_exact(u2, tol)) self.assertEqual(True, union.equals_exact(u2, tol))
qs = City.objects.filter(name='NotACity') qs = City.objects.filter(name='NotACity')
self.assertEqual(None, qs.unionagg(field_name='point')) 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

0 comments on commit a6a0800

Please sign in to comment.