summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-12-21 20:07:13 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2012-12-30 11:20:27 +0200
commitce3c71faf1ff83494193b48a6f99256d0628b2a2 (patch)
tree1ac903aaf7089d3b72384747169f7d5d31b156b8
parent807eff74396faba24ad420236d83e9716feffe1e (diff)
Minor improvement to proxy model handling
Refs #19385
-rw-r--r--django/db/models/sql/compiler.py2
-rw-r--r--django/db/models/sql/query.py8
2 files changed, 4 insertions, 6 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 16aa031e59..79b5d99452 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -255,8 +255,6 @@ class SQLCompiler(object):
result = []
if opts is None:
opts = self.query.model._meta
- # Skip all proxy to the root proxied model
- opts = opts.concrete_model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
aliases = set()
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 43ba519a68..87104f0d13 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -997,8 +997,7 @@ class Query(object):
whereas column determination is a later part, and side-effect, of
as_sql()).
"""
- # Skip all proxy models
- opts = self.model._meta.concrete_model._meta
+ opts = self.model._meta
root_alias = self.tables[0]
seen = {None: root_alias}
@@ -1013,7 +1012,8 @@ class Query(object):
a parent of 'opts' or if it is None this method is a no-op.
The 'alias' is the root alias for starting the join, 'seen' is a dict
- of model -> alias of existing joins.
+ of model -> alias of existing joins. It must also contain a mapping
+ of None -> some alias. This will be returned in the no-op case.
"""
if model in seen:
return seen[model]
@@ -1036,7 +1036,7 @@ class Query(object):
connection = (alias, int_opts.db_table, link_field.column, int_opts.pk.column)
alias = seen[int_model] = self.join(connection, nullable=False,
join_field=link_field)
- return alias
+ return alias or seen[None]
def remove_inherited_models(self):
"""