[py3] Removed unnecessary calls to .keys()
when computing the length of a dictionary. This fails on Python 3.
This commit is contained in:
parent
2ae58b20ec
commit
9299dc42ed
|
@ -3,7 +3,7 @@ from django.db.models.sql import compiler
|
||||||
class SQLCompiler(compiler.SQLCompiler):
|
class SQLCompiler(compiler.SQLCompiler):
|
||||||
def resolve_columns(self, row, fields=()):
|
def resolve_columns(self, row, fields=()):
|
||||||
values = []
|
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):
|
for value, field in map(None, row[index_extra_select:], fields):
|
||||||
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
|
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
|
||||||
value in (0, 1)):
|
value in (0, 1)):
|
||||||
|
|
|
@ -10,7 +10,7 @@ class SQLCompiler(compiler.SQLCompiler):
|
||||||
rn_offset = 1
|
rn_offset = 1
|
||||||
else:
|
else:
|
||||||
rn_offset = 0
|
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)
|
values = [self.query.convert_values(v, None, connection=self.connection)
|
||||||
for v in row[rn_offset:index_start]]
|
for v in row[rn_offset:index_start]]
|
||||||
for value, field in map(None, row[index_start:], fields):
|
for value, field in map(None, row[index_start:], fields):
|
||||||
|
|
|
@ -779,7 +779,7 @@ class Model(six.with_metaclass(ModelBase, object)):
|
||||||
lookup_kwargs[str(field_name)] = lookup_value
|
lookup_kwargs[str(field_name)] = lookup_value
|
||||||
|
|
||||||
# some fields were skipped, no reason to do the check
|
# 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
|
continue
|
||||||
|
|
||||||
qs = model_class._default_manager.filter(**lookup_kwargs)
|
qs = model_class._default_manager.filter(**lookup_kwargs)
|
||||||
|
|
|
@ -786,7 +786,7 @@ class SQLCompiler(object):
|
||||||
row = self.resolve_columns(row, fields)
|
row = self.resolve_columns(row, fields)
|
||||||
|
|
||||||
if has_aggregate_select:
|
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)
|
aggregate_end = aggregate_start + len(self.query.aggregate_select)
|
||||||
row = tuple(row[:aggregate_start]) + tuple([
|
row = tuple(row[:aggregate_start]) + tuple([
|
||||||
self.query.resolve_aggregate(value, aggregate, self.connection)
|
self.query.resolve_aggregate(value, aggregate, self.connection)
|
||||||
|
|
Loading…
Reference in New Issue