summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-12-30 12:10:15 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2012-12-30 12:10:15 +0200
commitf80a1934cdb465c70ecc215fdf867e555a670623 (patch)
tree288a09eba3bf6075b5ac33a6a0bbcadcbaf4af01
parentce3c71faf1ff83494193b48a6f99256d0628b2a2 (diff)
Fixed GIS regression in get_default_columns()
I changed the normal compiler's get_default_columns() but didn't change the copy-pasted code in GIS compiler's get_default_columns(). Refs #19385
-rw-r--r--django/contrib/gis/db/models/sql/compiler.py21
1 files changed, 4 insertions, 17 deletions
diff --git a/django/contrib/gis/db/models/sql/compiler.py b/django/contrib/gis/db/models/sql/compiler.py
index 81a9941c9e..fc53d08ffd 100644
--- a/django/contrib/gis/db/models/sql/compiler.py
+++ b/django/contrib/gis/db/models/sql/compiler.py
@@ -119,29 +119,16 @@ class GeoSQLCompiler(compiler.SQLCompiler):
result = []
if opts is None:
opts = self.query.model._meta
- # Skip all proxy to the root proxied model
- opts = opts.concrete_model._meta
aliases = set()
only_load = self.deferred_to_columns()
-
+ seen = self.query.included_inherited_models.copy()
if start_alias:
- seen = {None: start_alias}
+ seen[None] = start_alias
for field, model in opts.get_fields_with_model():
if from_parent and model is not None and issubclass(from_parent, model):
+ # Avoid loading data for already loaded parents.
continue
- if start_alias:
- try:
- alias = seen[model]
- except KeyError:
- link_field = opts.get_ancestor_link(model)
- alias = self.query.join((start_alias, model._meta.db_table,
- link_field.column, model._meta.pk.column))
- seen[model] = alias
- else:
- # If we're starting from the base model of the queryset, the
- # aliases will have already been set up in pre_sql_setup(), so
- # we can save time here.
- alias = self.query.included_inherited_models[model]
+ alias = self.query.join_parent_model(opts, model, start_alias, seen)
table = self.query.alias_map[alias].table_name
if table in only_load and field.column not in only_load[table]:
continue