mtre...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 09c1b03

queryset-refactor: A few bits of code cleanup.

  • Participants
  • Parent commits cf5df37
  • Branches queryset-refactor

Comments (0)

Files changed (2)

File django/db/models/sql/

         the model.
         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()
             for col in
         # 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[RHS_ALIAS] = new_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]
             if lhs in change_map:
                 data = list(data)
         Returns the number of tables in this query with a non-zero reference
-        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=(),
             promote=False, outer_if_first=False, nullable=False):

File django/db/models/sql/

         parameters. This provides a way to insert NULL and DEFAULT keywords
         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 = [], []
         for field, val in insert_values:
             if hasattr(field, 'get_placeholder'):