From 92d43522839fd9ec945d8c018de78770bec04ee1 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 14 Jan 2011 05:04:14 +0000 Subject: [PATCH] Cleaned up the ORM slightly. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15203 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index b0565524bb..1c58a24d45 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1212,11 +1212,10 @@ class Query(object): dupe_set = set() exclusions = set() extra_filters = [] + int_alias = None for pos, name in enumerate(names): - try: + if int_alias is not None: exclusions.add(int_alias) - except NameError: - pass exclusions.add(alias) last.append(len(joins)) if name == 'pk': @@ -1375,10 +1374,11 @@ class Query(object): joins.append(alias) for (dupe_opts, dupe_col) in dupe_set: - try: - self.update_dupe_avoidance(dupe_opts, dupe_col, int_alias) - except NameError: - self.update_dupe_avoidance(dupe_opts, dupe_col, alias) + if int_alias is None: + to_avoid = alias + else: + to_avoid = int_alias + self.update_dupe_avoidance(dupe_opts, dupe_col, to_avoid) if pos != len(names) - 1: if pos == len(names) - 2: