MCPcopy
hub / github.com/tortoise/tortoise-orm / _fk_getter

Function _fk_getter

tortoise/models.py:105–114  ·  view source on GitHub ↗
(
    self: Model, _key: str, ftype: type[Model], relation_field: str, to_field: str
)

Source from the content-addressed store, hash-verified

103
104
105def _fk_getter(
106 self: Model, _key: str, ftype: type[Model], relation_field: str, to_field: str
107) -> Awaitable:
108 try:
109 return getattr(self, _key)
110 except AttributeError:
111 value = getattr(self, relation_field)
112 if value is not None:
113 return ftype.filter(**{to_field: value}).first()
114 return NoneAwaitable
115
116
117def _rfk_getter(

Callers

nothing calls this directly

Calls 2

firstMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…