Skip to content

Commit

Permalink
Added local 'qn' variable for backend.quote_name in django.db.models.…
Browse files Browse the repository at this point in the history
…query.lookup_inner

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3323 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jul 11, 2006
1 parent c262e19 commit a17a9d1
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions django/db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ def find_field(name, field_list, related_query):
return matches[0]

def lookup_inner(path, lookup_type, value, opts, table, column):
qn = backend.quote_name
joins, where, params = SortedDict(), [], []
current_opts = opts
current_table = table
Expand Down Expand Up @@ -838,11 +839,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
# Check whether an intermediate join is required between current_table
# and new_table.
if intermediate_table:
joins[backend.quote_name(current_table)] = (
backend.quote_name(intermediate_table), "LEFT OUTER JOIN",
"%s.%s = %s.%s" % \
(backend.quote_name(table), backend.quote_name(current_opts.pk.column),
backend.quote_name(current_table), backend.quote_name(intermediate_column))
joins[qn(current_table)] = (
qn(intermediate_table), "LEFT OUTER JOIN",
"%s.%s = %s.%s" % (qn(table), qn(current_opts.pk.column), qn(current_table), qn(intermediate_column))
)

if path:
Expand All @@ -858,11 +857,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
else:
# There are 1 or more name queries pending, and we have ruled out
# any shortcuts; therefore, a join is required.
joins[backend.quote_name(new_table)] = (
backend.quote_name(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" %
(backend.quote_name(current_table), backend.quote_name(join_column),
backend.quote_name(new_table), backend.quote_name(new_column))
joins[qn(new_table)] = (
qn(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" % (qn(current_table), qn(join_column), qn(new_table), qn(new_column))
)
# If we have made the join, we don't need to tell subsequent
# recursive calls about the column name we joined on.
Expand All @@ -884,11 +881,9 @@ def lookup_inner(path, lookup_type, value, opts, table, column):
# RelatedObject is from a 1-N relation.
# Join is required; query operates on joined table.
column = new_opts.pk.name
joins[backend.quote_name(new_table)] = (
backend.quote_name(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" %
(backend.quote_name(current_table), backend.quote_name(join_column),
backend.quote_name(new_table), backend.quote_name(new_column))
joins[qn(new_table)] = (
qn(new_opts.db_table), "INNER JOIN",
"%s.%s = %s.%s" % (qn(current_table), qn(join_column), qn(new_table), qn(new_column))
)
current_table = new_table
else:
Expand Down

0 comments on commit a17a9d1

Please sign in to comment.