MCPcopy
hub / github.com/ormar-orm/ormar / select_all

Method select_all

ormar/queryset/queryset.py:400–424  ·  view source on GitHub ↗

By default adds only directly related models. If follow=True is set it adds also related models of related models. To not get stuck in an infinite loop as related models also keep a relation to parent model visited models set is kept. That way already visi

(self, follow: bool = False)

Source from the content-addressed store, hash-verified

398 return self.rebuild_self(select_related=related)
399
400 def select_all(self, follow: bool = False) -> "QuerySet[T]":
401 """
402 By default adds only directly related models.
403
404 If follow=True is set it adds also related models of related models.
405
406 To not get stuck in an infinite loop as related models also keep a relation
407 to parent model visited models set is kept.
408
409 That way already visited models that are nested are loaded, but the load do not
410 follow them inside. So Model A -> Model B -> Model C -> Model A -> Model X
411 will load second Model A but will never follow into Model X.
412 Nested relations of those kind need to be loaded manually.
413
414 :param follow: flag to trigger deep save -
415 by default only directly related models are saved
416 with follow=True also related models of related models are saved
417 :type follow: bool
418 :return: reloaded Model
419 :rtype: Model
420 """
421 relations = list(self.model.extract_related_names())
422 if follow:
423 relations = self.model._iterate_related_models()
424 return self.rebuild_self(select_related=relations)
425
426 def prefetch_related(
427 self, related: Union[list, str, FieldAccessor]

Callers 11

get_departmentFunction · 0.45
get_department_excludeFunction · 0.45
test_load_all_fk_relFunction · 0.45
test_load_all_with_orderFunction · 0.45
test_loading_nestedFunction · 0.45

Calls 3

rebuild_selfMethod · 0.95
extract_related_namesMethod · 0.80

Tested by 11

get_departmentFunction · 0.36
get_department_excludeFunction · 0.36
test_load_all_fk_relFunction · 0.36
test_load_all_with_orderFunction · 0.36
test_loading_nestedFunction · 0.36