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

Function _ro2o_getter

tortoise/models.py:127–135  ·  view source on GitHub ↗
(
    self: Model, _key: str, ftype: type[Model], frelfield: str, from_field: str
)

Source from the content-addressed store, hash-verified

125
126
127def _ro2o_getter(
128 self: Model, _key: str, ftype: type[Model], frelfield: str, from_field: str
129) -> QuerySetSingle[Model | None]:
130 if hasattr(self, _key):
131 return getattr(self, _key)
132
133 val = ftype.filter(**{frelfield: getattr(self, from_field)}).first()
134 setattr(self, _key, val)
135 return val
136
137
138def _m2m_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…