From 161e26c2ec9f88bf0395941aaa2fd193b110affd Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Thu, 22 Aug 2013 10:42:10 +0300 Subject: [1.6.x] Fixed #20955 -- select_related regression In cases where the same connection (from model A to model B along the same field) was needed multiple times in a select_related query, the join setup code mistakenly reused an existing join. Backpatch of 8d65b6082c8bf5df25608d8733470879a8a61d7d. Conflicts: django/db/models/sql/compiler.py tests/queries/tests.py --- django/db/models/sql/compiler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index f70750abed..e768cedf88 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -687,9 +687,8 @@ class SQLCompiler(object): # Use True here because we are looking at the _reverse_ side of # the relation, which is always nullable. new_nullable = True - table = model._meta.db_table - self.fill_related_selections(model._meta, table, cur_depth+1, - next, restricted, new_nullable) + self.fill_related_selections(model._meta, alias, cur_depth + 1, + next, restricted, new_nullable) def deferred_to_columns(self): """ -- cgit v1.3