From 0b980ef85779835d5600564f1327c478712a4882 Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitão" Date: Sat, 14 Jun 2014 12:48:47 +0200 Subject: Removed unnecessary attribute assigment to SQLCompiler. --- django/db/models/sql/compiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/db/models/sql/compiler.py') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 6792824ecd..fbb0152874 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -96,7 +96,7 @@ class SQLCompiler(object): # However we do not want to get rid of stuff done in pre_sql_setup(), # as the pre_sql_setup will modify query state in a way that forbids # another run of it. - self.refcounts_before = self.query.alias_refcount.copy() + refcounts_before = self.query.alias_refcount.copy() out_cols, s_params = self.get_columns(with_col_aliases) ordering, o_params, ordering_group_by = self.get_ordering() @@ -169,7 +169,7 @@ class SQLCompiler(object): result.append(self.connection.ops.for_update_sql(nowait=nowait)) # Finally do cleanup - get rid of the joins we created above. - self.query.reset_refcounts(self.refcounts_before) + self.query.reset_refcounts(refcounts_before) return ' '.join(result), tuple(params) -- cgit v1.3 From d2cbcbcc76a0718d45ca2305c8a55b86eb4c58c1 Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitão" Date: Sat, 14 Jun 2014 12:50:18 +0200 Subject: Improved code style of Query.table_alias() usage. --- django/db/models/sql/compiler.py | 2 +- django/db/models/sql/query.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'django/db/models/sql/compiler.py') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index fbb0152874..59b31dcb79 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -546,7 +546,7 @@ class SQLCompiler(object): result.append('%s%s%s' % (connector, qn(name), alias_str)) first = False for t in self.query.extra_tables: - alias, unused = self.query.table_alias(t) + alias, _ = self.query.table_alias(t) # Only add the alias if it's not already present (the table_alias() # calls increments the refcount, so an alias refcount of one means # this is the only reference. diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 292322b9cb..ff86e8b45b 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -664,16 +664,16 @@ class Query(object): If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused. """ - current = self.table_map.get(table_name) - if not create and current: - alias = current[0] + alias_list = self.table_map.get(table_name) + if not create and alias_list: + alias = alias_list[0] self.alias_refcount[alias] += 1 return alias, False # Create a new alias for this table. - if current: + if alias_list: alias = '%s%d' % (self.alias_prefix, len(self.alias_map) + 1) - current.append(alias) + alias_list.append(alias) else: # The first occurrence of a table uses the table name directly. alias = table_name @@ -900,7 +900,7 @@ class Query(object): return alias # No reuse is possible, so we need a new alias. - alias, _ = self.table_alias(table, True) + alias, _ = self.table_alias(table, create=True) if not lhs: # Not all tables need to be joined to anything. No join type # means the later columns are ignored. -- cgit v1.3