MCPcopy
hub / github.com/django/django / add_immediate_loading

Method add_immediate_loading

django/db/models/sql/query.py:2525–2547  ·  view source on GitHub ↗

Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, remove

(self, field_names)

Source from the content-addressed store, hash-verified

2523 self.deferred_loading = new_only, True
2524
2525 def add_immediate_loading(self, field_names):
2526 """
2527 Add the given list of model field names to the set of fields to
2528 retrieve when the SQL is executed ("immediate loading" fields). The
2529 field names replace any existing immediate loading field names. If
2530 there are field names already specified for deferred loading, remove
2531 those names from the new field_names before storing the new names
2532 for immediate loading. (That is, immediate loading overrides any
2533 existing immediate values, but respects existing deferrals.)
2534 """
2535 existing, defer = self.deferred_loading
2536 field_names = set(field_names)
2537 if "pk" in field_names:
2538 field_names.remove("pk")
2539 field_names.add(self.get_meta().pk.name)
2540
2541 if defer:
2542 # Remove any existing deferred names from the current set before
2543 # setting the new names.
2544 self.deferred_loading = field_names.difference(existing), False
2545 else:
2546 # Replace any existing "immediate load" field names.
2547 self.deferred_loading = frozenset(field_names), False
2548
2549 def set_annotation_mask(self, names):
2550 """Set the mask of annotations that will be returned by the SELECT."""

Callers 1

onlyMethod · 0.80

Calls 4

get_metaMethod · 0.95
removeMethod · 0.45
addMethod · 0.45
differenceMethod · 0.45

Tested by

no test coverage detected