Removed unnecessary Query.get_loaded_field_names_cb() and Query.deferred_to_data()'s callback argument.

This commit is contained in:
Mariusz Felisiak 2022-03-31 07:40:32 +02:00
parent 0a3c6fe6b2
commit d7eb500338
2 changed files with 6 additions and 13 deletions

View File

@ -1295,7 +1295,7 @@ class SQLCompiler:
dictionary. dictionary.
""" """
columns = {} columns = {}
self.query.deferred_to_data(columns, self.query.get_loaded_field_names_cb) self.query.deferred_to_data(columns)
return columns return columns
def get_converters(self, expressions): def get_converters(self, expressions):

View File

@ -703,7 +703,7 @@ class Query(BaseExpression):
self.order_by = rhs.order_by or self.order_by self.order_by = rhs.order_by or self.order_by
self.extra_order_by = rhs.extra_order_by or self.extra_order_by self.extra_order_by = rhs.extra_order_by or self.extra_order_by
def deferred_to_data(self, target, callback): def deferred_to_data(self, target):
""" """
Convert the self.deferred_loading data structure to an alternate data Convert the self.deferred_loading data structure to an alternate data
structure, describing the field that *will* be loaded. This is used to structure, describing the field that *will* be loaded. This is used to
@ -713,9 +713,6 @@ class Query(BaseExpression):
the result, only those that have field restrictions in place. the result, only those that have field restrictions in place.
The "target" parameter is the instance that is populated (in place). The "target" parameter is the instance that is populated (in place).
The "callback" is a function that is called whenever a (model, field)
pair need to be added to "target". It accepts three parameters:
"target", and the model and list of fields being added for that model.
""" """
field_names, defer = self.deferred_loading field_names, defer = self.deferred_loading
if not field_names: if not field_names:
@ -770,8 +767,8 @@ class Query(BaseExpression):
# "else" branch here. # "else" branch here.
if model in workset: if model in workset:
workset[model].update(values) workset[model].update(values)
for model, values in workset.items(): for model, fields in workset.items():
callback(target, model, values) target[model] = {f.attname for f in fields}
else: else:
for model, values in must_include.items(): for model, values in must_include.items():
if model in seen: if model in seen:
@ -786,8 +783,8 @@ class Query(BaseExpression):
# only "must include" fields are pulled in. # only "must include" fields are pulled in.
for model in orig_opts.get_parent_list(): for model in orig_opts.get_parent_list():
seen.setdefault(model, set()) seen.setdefault(model, set())
for model, values in seen.items(): for model, fields in seen.items():
callback(target, model, values) target[model] = {f.attname for f in fields}
def table_alias(self, table_name, create=False, filtered_relation=None): def table_alias(self, table_name, create=False, filtered_relation=None):
""" """
@ -2341,10 +2338,6 @@ class Query(BaseExpression):
# Replace any existing "immediate load" field names. # Replace any existing "immediate load" field names.
self.deferred_loading = frozenset(field_names), False self.deferred_loading = frozenset(field_names), False
def get_loaded_field_names_cb(self, target, model, fields):
"""Callback used by get_deferred_field_names()."""
target[model] = {f.attname for f in fields}
def set_annotation_mask(self, names): def set_annotation_mask(self, names):
"""Set the mask of annotations that will be returned by the SELECT.""" """Set the mask of annotations that will be returned by the SELECT."""
if names is None: if names is None: