mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
queryset-refactor: A few bits of code cleanup.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7454 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
28b1c9c1c9
commit
dd0c5855e9
@ -357,7 +357,7 @@ class Query(object):
|
|||||||
the model.
|
the model.
|
||||||
"""
|
"""
|
||||||
qn = self.quote_name_unless_alias
|
qn = self.quote_name_unless_alias
|
||||||
result = ['(%s) AS %s' % (col, alias) for alias, col in self.extra_select.items()]
|
result = ['(%s) AS %s' % (col, alias) for alias, col in self.extra_select.iteritems()]
|
||||||
aliases = self.extra_select.keys()
|
aliases = self.extra_select.keys()
|
||||||
if self.select:
|
if self.select:
|
||||||
for col in self.select:
|
for col in self.select:
|
||||||
@ -633,7 +633,7 @@ class Query(object):
|
|||||||
col.relabel_aliases(change_map)
|
col.relabel_aliases(change_map)
|
||||||
|
|
||||||
# 2. Rename the alias in the internal table/alias datastructures.
|
# 2. Rename the alias in the internal table/alias datastructures.
|
||||||
for old_alias, new_alias in change_map.items():
|
for old_alias, new_alias in change_map.iteritems():
|
||||||
alias_data = list(self.alias_map[old_alias])
|
alias_data = list(self.alias_map[old_alias])
|
||||||
alias_data[RHS_ALIAS] = new_alias
|
alias_data[RHS_ALIAS] = new_alias
|
||||||
|
|
||||||
@ -657,7 +657,7 @@ class Query(object):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# 3. Update any joins that refer to the old alias.
|
# 3. Update any joins that refer to the old alias.
|
||||||
for alias, data in self.alias_map.items():
|
for alias, data in self.alias_map.iteritems():
|
||||||
lhs = data[LHS_ALIAS]
|
lhs = data[LHS_ALIAS]
|
||||||
if lhs in change_map:
|
if lhs in change_map:
|
||||||
data = list(data)
|
data = list(data)
|
||||||
@ -706,7 +706,7 @@ class Query(object):
|
|||||||
Returns the number of tables in this query with a non-zero reference
|
Returns the number of tables in this query with a non-zero reference
|
||||||
count.
|
count.
|
||||||
"""
|
"""
|
||||||
return len([1 for count in self.alias_refcount.values() if count])
|
return len([1 for count in self.alias_refcount.itervalues() if count])
|
||||||
|
|
||||||
def join(self, connection, always_create=False, exclusions=(),
|
def join(self, connection, always_create=False, exclusions=(),
|
||||||
promote=False, outer_if_first=False, nullable=False):
|
promote=False, outer_if_first=False, nullable=False):
|
||||||
|
@ -295,9 +295,6 @@ class InsertQuery(Query):
|
|||||||
parameters. This provides a way to insert NULL and DEFAULT keywords
|
parameters. This provides a way to insert NULL and DEFAULT keywords
|
||||||
into the query, for example.
|
into the query, for example.
|
||||||
"""
|
"""
|
||||||
# keys() and values() return items in the same order, providing the
|
|
||||||
# dictionary hasn't changed between calls. So the dual iteration here
|
|
||||||
# works as intended.
|
|
||||||
placeholders, values = [], []
|
placeholders, values = [], []
|
||||||
for field, val in insert_values:
|
for field, val in insert_values:
|
||||||
if hasattr(field, 'get_placeholder'):
|
if hasattr(field, 'get_placeholder'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user