MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / Load

Class Load

lib/sqlalchemy/orm/strategy_options.py:971–1334  ·  view source on GitHub ↗

Represents loader options which modify the state of a ORM-enabled :class:`_sql.Select` or a legacy :class:`_query.Query` in order to affect how various mapped attributes are loaded. The :class:`_orm.Load` object is in most cases used implicitly behind the scenes when one makes use o

Source from the content-addressed store, hash-verified

969
970
971class Load(_AbstractLoad):
972 """Represents loader options which modify the state of a
973 ORM-enabled :class:`_sql.Select` or a legacy :class:`_query.Query` in
974 order to affect how various mapped attributes are loaded.
975
976 The :class:`_orm.Load` object is in most cases used implicitly behind the
977 scenes when one makes use of a query option like :func:`_orm.joinedload`,
978 :func:`_orm.defer`, or similar. It typically is not instantiated directly
979 except for in some very specific cases.
980
981 .. seealso::
982
983 :ref:`orm_queryguide_relationship_per_entity_wildcard` - illustrates an
984 example where direct use of :class:`_orm.Load` may be useful
985
986 """
987
988 __slots__ = (
989 "path",
990 "context",
991 "additional_source_entities",
992 )
993
994 _traverse_internals = [
995 ("path", visitors.ExtendedInternalTraversal.dp_has_cache_key),
996 (
997 "context",
998 visitors.InternalTraversal.dp_has_cache_key_list,
999 ),
1000 ("propagate_to_loaders", visitors.InternalTraversal.dp_boolean),
1001 (
1002 "additional_source_entities",
1003 visitors.InternalTraversal.dp_has_cache_key_list,
1004 ),
1005 ]
1006 _cache_key_traversal = None
1007
1008 path: PathRegistry
1009 context: Tuple[_LoadElement, ...]
1010 additional_source_entities: Tuple[_InternalEntityType[Any], ...]
1011
1012 def __init__(self, entity: _EntityType[Any]):
1013 insp = cast("Union[Mapper[Any], AliasedInsp[Any]]", inspect(entity))
1014 insp._post_inspect
1015
1016 self.path = insp._path_registry
1017 self.context = ()
1018 self.propagate_to_loaders = False
1019 self.additional_source_entities = ()
1020
1021 def __str__(self) -> str:
1022 return f"Load({self.path[0]})"
1023
1024 @classmethod
1025 def _construct_for_existing_path(
1026 cls, path: _AbstractEntityRegistry
1027 ) -> Load:
1028 load = cls.__new__(cls)

Calls

no outgoing calls