msflib.models¶
Part of the msflib core package.
msflib.models
¶
msflib.models package. Attribute access is lazy (PEP 562) so importing one name doesn't force-import the others' dependencies.
base
¶
ModelBase
¶
Bases: SchemaBase
add_relationship(name: str, target: type[SQLModel], *, back_populates: str | None = None, link_model: type[SQLModel] | None = None, secondary=None, primaryjoin=None, secondaryjoin=None, viewonly: bool = False, lazy: str = 'selectin', **kwargs: Any) -> None
classmethod
¶
Attach a relationship to this model after class definition.
This wraps Mapper.add_property() so callers can avoid importing SQLAlchemy internals directly in application code.
Preferred SQLModel-style usage is to provide target and link_model
for many-to-many relations and let SQLAlchemy infer joins from foreign keys.
secondary/primaryjoin/secondaryjoin remain available for
advanced SQLAlchemy overrides.
Notes:
- Use either link_model or secondary (not both).
- Provide primaryjoin and secondaryjoin when join inference is
ambiguous or when explicit join control is required.
- lazy sets the relationship's default loader strategy (for example
"selectin"). Query-time options like selectinload(...) are
configured per query, not here.
- This method requires that cls be a mapped class with __mapper__
and, if link_model is provided, it must have __table__. Both
cls and target must be SQLModel classes with table=True.