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
This commit is contained in:
Anssi Kääriäinen 2012-12-30 12:10:15 +02:00
parent ce3c71faf1
commit f80a1934cd
1 changed files with 4 additions and 17 deletions

View File

@ -119,29 +119,16 @@ class GeoSQLCompiler(compiler.SQLCompiler):
result = [] result = []
if opts is None: if opts is None:
opts = self.query.model._meta opts = self.query.model._meta
# Skip all proxy to the root proxied model
opts = opts.concrete_model._meta
aliases = set() aliases = set()
only_load = self.deferred_to_columns() only_load = self.deferred_to_columns()
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_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.
continue continue
if start_alias: alias = self.query.join_parent_model(opts, model, start_alias, seen)
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]
table = self.query.alias_map[alias].table_name table = self.query.alias_map[alias].table_name
if table in only_load and field.column not in only_load[table]: if table in only_load and field.column not in only_load[table]:
continue continue