diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-25 15:01:40 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-25 15:01:40 +0000 |
| commit | bb9261197996464edc6398d194ec4e0b00d1c555 (patch) | |
| tree | 8865a97391a9d91a5f69c1d9f081de620c3d2023 /django/db/models/sql/query.py | |
| parent | 6657d476d03fbc5cd1d9a64922f2a8b7c97ddf05 (diff) | |
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
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 502769b932..864563ed8e 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -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 |
