some cleanup of unused relations code, introduced caching of related_names and props on model, set profiling

This commit is contained in:
collerek
2020-11-12 08:11:40 +01:00
parent 1242e5d600
commit e743286008
11 changed files with 95 additions and 466 deletions

View File

@ -7,7 +7,6 @@ from ormar.fields.many_to_many import ManyToManyField
from ormar.relations.relation import Relation, RelationType
from ormar.relations.utils import (
get_relations_sides_and_names,
register_missing_relation,
)
if TYPE_CHECKING: # pragma no cover
@ -42,8 +41,6 @@ class RelationsManager:
to=field.to,
through=getattr(field, "through", None),
)
if field.name not in self._related_names:
self._related_names.append(field.name)
def __contains__(self, item: str) -> bool:
return item in self._related_names
@ -69,9 +66,10 @@ class RelationsManager:
)
parent_relation = parent._orm._get(child_name)
if not parent_relation:
parent_relation = register_missing_relation(parent, child, child_name)
parent_relation.add(child) # type: ignore
if parent_relation:
# print('missing', child_name)
# parent_relation = register_missing_relation(parent, child, child_name)
parent_relation.add(child) # type: ignore
child_relation = child._orm._get(to_name)
if child_relation: