Added local 'qn' variable for backend.quote_name in django.db.models.query.lookup_inner

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3323 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-07-11 03:27:10 +00:00
parent c262e19670
commit a17a9d1474
1 changed files with 10 additions and 15 deletions

View File

@ -755,6 +755,7 @@ def find_field(name, field_list, related_query):
return matches[0] return matches[0]
def lookup_inner(path, lookup_type, value, opts, table, column): def lookup_inner(path, lookup_type, value, opts, table, column):
qn = backend.quote_name
joins, where, params = SortedDict(), [], [] joins, where, params = SortedDict(), [], []
current_opts = opts current_opts = opts
current_table = table current_table = table
@ -838,11 +839,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
# Check whether an intermediate join is required between current_table # Check whether an intermediate join is required between current_table
# and new_table. # and new_table.
if intermediate_table: if intermediate_table:
joins[backend.quote_name(current_table)] = ( joins[qn(current_table)] = (
backend.quote_name(intermediate_table), "LEFT OUTER JOIN", qn(intermediate_table), "LEFT OUTER JOIN",
"%s.%s = %s.%s" % \ "%s.%s = %s.%s" % (qn(table), qn(current_opts.pk.column), qn(current_table), qn(intermediate_column))
(backend.quote_name(table), backend.quote_name(current_opts.pk.column),
backend.quote_name(current_table), backend.quote_name(intermediate_column))
) )
if path: if path:
@ -858,11 +857,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
else: else:
# There are 1 or more name queries pending, and we have ruled out # There are 1 or more name queries pending, and we have ruled out
# any shortcuts; therefore, a join is required. # any shortcuts; therefore, a join is required.
joins[backend.quote_name(new_table)] = ( joins[qn(new_table)] = (
backend.quote_name(new_opts.db_table), "INNER JOIN", qn(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" % "%s.%s = %s.%s" % (qn(current_table), qn(join_column), qn(new_table), qn(new_column))
(backend.quote_name(current_table), backend.quote_name(join_column),
backend.quote_name(new_table), backend.quote_name(new_column))
) )
# If we have made the join, we don't need to tell subsequent # If we have made the join, we don't need to tell subsequent
# recursive calls about the column name we joined on. # recursive calls about the column name we joined on.
@ -884,11 +881,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
# RelatedObject is from a 1-N relation. # RelatedObject is from a 1-N relation.
# Join is required; query operates on joined table. # Join is required; query operates on joined table.
column = new_opts.pk.name column = new_opts.pk.name
joins[backend.quote_name(new_table)] = ( joins[qn(new_table)] = (
backend.quote_name(new_opts.db_table), "INNER JOIN", qn(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" % "%s.%s = %s.%s" % (qn(current_table), qn(join_column), qn(new_table), qn(new_column))
(backend.quote_name(current_table), backend.quote_name(join_column),
backend.quote_name(new_table), backend.quote_name(new_column))
) )
current_table = new_table current_table = new_table
else: else: