1
0
mirror of https://github.com/django/django.git synced 2025-07-07 03:09:22 +00:00

queryset-refactor: Fixed a bug in the internal Query.join_map datastructure.

Could result in some incorrect results(?) when using the same table multiple
times in a query.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7459 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-04-25 15:01:40 +00:00
parent 6657d476d0
commit bb92611979

View File

@ -673,7 +673,9 @@ class Query(object):
alias_data[RHS_ALIAS] = new_alias
t = self.rev_join_map[old_alias]
self.join_map[t] = new_alias
data = list(self.join_map[t])
data[data.index(old_alias)] = new_alias
self.join_map[t] = tuple(data)
self.rev_join_map[new_alias] = t
del self.rev_join_map[old_alias]
self.alias_refcount[new_alias] = self.alias_refcount[old_alias]
@ -778,12 +780,12 @@ class Query(object):
else:
lhs_table = lhs
t_ident = (lhs_table, table, lhs_col, col)
alias = self.join_map.get(t_ident)
if alias and not always_create and alias not in exclusions:
self.ref_alias(alias)
if promote:
self.promote_alias(alias)
return alias
for alias in self.join_map.get(t_ident, ()):
if alias and not always_create and alias not in exclusions:
self.ref_alias(alias)
if promote:
self.promote_alias(alias)
return alias
# No reuse is possible, so we need a new alias.
alias, _ = self.table_alias(table, True)
@ -797,7 +799,10 @@ class Query(object):
join_type = self.INNER
join = (table, alias, join_type, lhs, lhs_col, col, nullable)
self.alias_map[alias] = join
self.join_map[t_ident] = alias
if t_ident in self.join_map:
self.join_map[t_ident] += (alias,)
else:
self.join_map[t_ident] = (alias,)
self.rev_join_map[alias] = t_ident
return alias