Django

Code

Changeset 7459

Show
Ignore:
Timestamp:
04/25/08 10:01:40 (2 months ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/sql/query.py

    r7457 r7459  
    674674 
    675675            t = self.rev_join_map[old_alias] 
    676             self.join_map[t] = new_alias 
     676            data = list(self.join_map[t]) 
     677            data[data.index(old_alias)] = new_alias 
     678            self.join_map[t] = tuple(data) 
    677679            self.rev_join_map[new_alias] = t 
    678680            del self.rev_join_map[old_alias] 
     
    779781            lhs_table = lhs 
    780782        t_ident = (lhs_table, table, lhs_col, col) 
    781         alias = self.join_map.get(t_ident) 
    782         if alias and not always_create and alias not in exclusions: 
    783             self.ref_alias(alias) 
    784             if promote: 
    785                 self.promote_alias(alias) 
    786             return alias 
     783        for alias in self.join_map.get(t_ident, ()): 
     784            if alias and not always_create and alias not in exclusions: 
     785                self.ref_alias(alias) 
     786                if promote: 
     787                    self.promote_alias(alias) 
     788                return alias 
    787789 
    788790        # No reuse is possible, so we need a new alias. 
     
    798800        join = (table, alias, join_type, lhs, lhs_col, col, nullable) 
    799801        self.alias_map[alias] = join 
    800         self.join_map[t_ident] = alias 
     802        if t_ident in self.join_map: 
     803            self.join_map[t_ident] += (alias,) 
     804        else: 
     805            self.join_map[t_ident] = (alias,) 
    801806        self.rev_join_map[alias] = t_ident 
    802807        return alias