Skip to content

Commit

Permalink
[py3] Removed unnecessary calls to .keys()
Browse files Browse the repository at this point in the history
when computing the length of a dictionary. This fails on Python 3.
  • Loading branch information
aaugustin committed Aug 14, 2012
1 parent 2ae58b2 commit 9299dc4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion django/db/backends/mysql/compiler.py
Expand Up @@ -3,7 +3,7 @@
class SQLCompiler(compiler.SQLCompiler):
def resolve_columns(self, row, fields=()):
values = []
index_extra_select = len(self.query.extra_select.keys())
index_extra_select = len(self.query.extra_select)
for value, field in map(None, row[index_extra_select:], fields):
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
value in (0, 1)):
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/oracle/compiler.py
Expand Up @@ -10,7 +10,7 @@ def resolve_columns(self, row, fields=()):
rn_offset = 1
else:
rn_offset = 0
index_start = rn_offset + len(self.query.extra_select.keys())
index_start = rn_offset + len(self.query.extra_select)
values = [self.query.convert_values(v, None, connection=self.connection)
for v in row[rn_offset:index_start]]
for value, field in map(None, row[index_start:], fields):
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/base.py
Expand Up @@ -779,7 +779,7 @@ def _perform_unique_checks(self, unique_checks):
lookup_kwargs[str(field_name)] = lookup_value

# some fields were skipped, no reason to do the check
if len(unique_check) != len(lookup_kwargs.keys()):
if len(unique_check) != len(lookup_kwargs):
continue

qs = model_class._default_manager.filter(**lookup_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/sql/compiler.py
Expand Up @@ -786,7 +786,7 @@ def results_iter(self):
row = self.resolve_columns(row, fields)

if has_aggregate_select:
aggregate_start = len(self.query.extra_select.keys()) + len(self.query.select)
aggregate_start = len(self.query.extra_select) + len(self.query.select)
aggregate_end = aggregate_start + len(self.query.aggregate_select)
row = tuple(row[:aggregate_start]) + tuple([
self.query.resolve_aggregate(value, aggregate, self.connection)
Expand Down

0 comments on commit 9299dc4

Please sign in to comment.