1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #10251 -- Fixed model inheritance when there's also an explicit pk field.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9970 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2009-03-04 07:20:08 +00:00
parent 0e93f60c7f
commit dfd7a6c781
3 changed files with 38 additions and 4 deletions

View File

@@ -643,14 +643,14 @@ class BaseQuery(object):
aliases = set()
if start_alias:
seen = {None: start_alias}
root_pk = opts.pk.column
for field, model in opts.get_fields_with_model():
if start_alias:
try:
alias = seen[model]
except KeyError:
link_field = opts.get_ancestor_link(model)
alias = self.join((start_alias, model._meta.db_table,
root_pk, model._meta.pk.column))
link_field.column, model._meta.pk.column))
seen[model] = alias
else:
# If we're starting from the base model of the queryset, the
@@ -1156,13 +1156,13 @@ class BaseQuery(object):
as_sql()).
"""
opts = self.model._meta
root_pk = opts.pk.column
root_alias = self.tables[0]
seen = {None: root_alias}
for field, model in opts.get_fields_with_model():
if model not in seen:
link_field = opts.get_ancestor_link(model)
seen[model] = self.join((root_alias, model._meta.db_table,
root_pk, model._meta.pk.column))
link_field.column, model._meta.pk.column))
self.included_inherited_models = seen
def remove_inherited_models(self):