class documentation

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 of a query option like :func:`_orm.joinedload`, :func:`_orm.defer`, or similar. It typically is not instantiated directly except for in some very specific cases. .. seealso:: :ref:`orm_queryguide_relationship_per_entity_wildcard` - illustrates an example where direct use of :class:`_orm.Load` may be useful

Method __getstate__ Undocumented
Method __init__ Undocumented
Method __setstate__ Undocumented
Method __str__ Undocumented
Method options Apply a series of options as sub-options to this :class:`_orm.Load` object.
Class Variable __slots__ Undocumented
Instance Variable context Undocumented
Instance Variable path Undocumented
Instance Variable propagate_to_loaders if True, indicate this option should be carried along to "secondary" SELECT statements that occur for relationship lazy loaders as well as attribute load / refresh operations.
Class Method _construct_for_existing_path Undocumented
Method _adapt_cached_option_to_uncached_option adapt this option to the "uncached" version of itself in a loader strategy context.
Method _adjust_for_extra_criteria Apply the current bound parameters in a QueryContext to all occurrences "extra_criteria" stored within this ``Load`` object, returning a new instance of this ``Load`` object.
Method _apply_to_parent apply this :class:`_orm.Load` object as a sub-option of another :class:`_orm.Load` object.
Method _clone_for_bind_strategy Undocumented
Method _process implemented by subclasses
Method _reconcile_query_entities_with_us called at process time to allow adjustment of the root entity inside of _LoadElement objects.
Class Variable _cache_key_traversal Undocumented
Class Variable _traverse_internals Undocumented

Inherited from _AbstractLoad:

Method contains_eager Indicate that the given attribute should be eagerly loaded from columns stated manually in the query.
Method defaultload Indicate an attribute should load using its default loader style.
Method defer Indicate that the given column-oriented attribute should be deferred, e.g. not loaded until accessed.
Method immediateload Indicate that the given attribute should be loaded using an immediate load with a per-attribute SELECT statement.
Method joinedload Indicate that the given attribute should be loaded using joined eager loading.
Method lazyload Indicate that the given attribute should be loaded using "lazy" loading.
Method load_only Indicate that for a particular entity, only the given list of column-based attribute names should be loaded; all others will be deferred.
Method noload Indicate that the given relationship attribute should remain unloaded.
Method process_compile_state Apply a modification to a given :class:`.ORMCompileState`.
Method process_compile_state_replaced_entities Apply a modification to a given :class:`.ORMCompileState`, given entities that were replaced by with_only_columns() or with_entities().
Method raiseload Indicate that the given attribute should raise an error if accessed.
Method selectin_polymorphic Indicate an eager load should take place for all attributes specific to a subclass.
Method selectinload Indicate that the given attribute should be loaded using SELECT IN eager loading.
Method subqueryload Indicate that the given attribute should be loaded using subquery eager loading.
Method undefer Indicate that the given column-oriented attribute should be undeferred, e.g. specified within the SELECT statement of the entity as a whole.
Method undefer_group Indicate that columns within the given deferred group name should be undeferred.
Method with_expression Apply an ad-hoc SQL expression to a "deferred expression" attribute.
Class Method _chop_path Undocumented
Method _coerce_strat Undocumented
Method _set_class_strategy Undocumented
Method _set_column_strategy Undocumented
Method _set_generic_strategy Undocumented
Method _set_relationship_strategy Undocumented
Class Variable _is_strategy_option Undocumented

Inherited from GenerativeOnTraversal (via _AbstractLoad):

Method _generate Undocumented

Inherited from HasShallowCopy (via _AbstractLoad, GenerativeOnTraversal):

Class Method _generate_shallow_copy Undocumented
Class Method _generate_shallow_from_dict Undocumented
Class Method _generate_shallow_to_dict Undocumented
Method _clone Create a shallow copy
Method _generated_shallow_copy_traversal Undocumented
Method _generated_shallow_from_dict_traversal Undocumented
Method _generated_shallow_to_dict_traversal Undocumented
Method _shallow_copy_to Undocumented
Method _shallow_from_dict Undocumented
Method _shallow_to_dict Undocumented

Inherited from CompileStateOption (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption):

Class Variable _is_compile_state Undocumented

Inherited from HasCacheKey (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption, CompileStateOption):

Class Variable inherit_cache Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass.
Class Method _generate_cache_attrs generate cache key dispatcher for a new class.
Class Method _generate_cache_key_for_object Undocumented
Method _gen_cache_key return an optional cache key.
Method _generate_cache_key return a cache key.
Class Variable _generated_cache_key_traversal Undocumented
Class Variable _hierarchy_supports_caching private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses.
Class Variable _is_has_cache_key Undocumented

Inherited from ORMOption (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption, CompileStateOption, HasCacheKey):

Class Variable _is_core Undocumented
Class Variable _is_criteria_option Undocumented
Class Variable _is_legacy_option Undocumented
Class Variable _is_user_defined Undocumented

Inherited from ExecutableOption (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption, CompileStateOption, HasCacheKey, ORMOption):

Class Variable __visit_name__ Undocumented

Inherited from HasCopyInternals (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption, CompileStateOption, HasCacheKey, ORMOption, ExecutableOption):

Method _copy_internals Reassign internal elements to be clones of themselves.

Inherited from HasTraverseInternals (via _AbstractLoad, GenerativeOnTraversal, HasShallowCopy, LoaderOption, CompileStateOption, HasCacheKey, ORMOption, ExecutableOption, HasCopyInternals):

Method get_children Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`.
Class Variable _is_immutable Undocumented
def __getstate__(self): (source)

Undocumented

def __init__(self, entity: _EntityType[Any]): (source)

Undocumented

def __setstate__(self, state): (source)

Undocumented

def __str__(self) -> str: (source)

Undocumented

@_generative
def options(self, *opts: _AbstractLoad) -> Self: (source)

Apply a series of options as sub-options to this :class:`_orm.Load` object. E.g.:: query = session.query(Author) query = query.options( joinedload(Author.book).options( load_only(Book.summary, Book.excerpt), joinedload(Book.citations).options( joinedload(Citation.author) ) ) ) :param \*opts: A series of loader option objects (ultimately :class:`_orm.Load` objects) which should be applied to the path specified by this :class:`_orm.Load` object. .. versionadded:: 1.3.6 .. seealso:: :func:`.defaultload` :ref:`orm_queryguide_relationship_sub_options`

Undocumented

Undocumented

propagate_to_loaders: bool = (source)

if True, indicate this option should be carried along to "secondary" SELECT statements that occur for relationship lazy loaders as well as attribute load / refresh operations.

@classmethod
def _construct_for_existing_path(cls, path: PathRegistry) -> Load: (source)

Undocumented

def _adapt_cached_option_to_uncached_option(self, context: QueryContext, uncached_opt: ORMOption) -> ORMOption: (source)

adapt this option to the "uncached" version of itself in a loader strategy context. given "self" which is an option from a cached query, as well as the corresponding option from the uncached version of the same query, return the option we should use in a new query, in the context of a loader strategy being asked to load related rows on behalf of that cached query, which is assumed to be building a new query based on entities passed to us from the cached query. Currently this routine chooses between "self" and "uncached" without manufacturing anything new. If the option is itself a loader strategy option which has a path, that path needs to match to the entities being passed to us by the cached query, so the :class:`_orm.Load` subclass overrides this to return "self". For all other options, we return the uncached form which may have changing state, such as a with_loader_criteria() option which will very often have new state. This routine could in the future involve generating a new option based on both inputs if use cases arise, such as if with_loader_criteria() needed to match up to ``AliasedClass`` instances given in the parent query. However, longer term it might be better to restructure things such that ``AliasedClass`` entities are always matched up on their cache key, instead of identity, in things like paths and such, so that this whole issue of "the uncached option does not match the entities" goes away. However this would make ``PathRegistry`` more complicated and difficult to debug as well as potentially less performant in that it would be hashing enormous cache keys rather than a simple AliasedInsp. UNLESS, we could get cache keys overall to be reliably hashed into something like an md5 key. .. versionadded:: 1.4.41

def _adjust_for_extra_criteria(self, context: QueryContext) -> Load: (source)

Apply the current bound parameters in a QueryContext to all occurrences "extra_criteria" stored within this ``Load`` object, returning a new instance of this ``Load`` object.

def _apply_to_parent(self, parent: Load): (source)

apply this :class:`_orm.Load` object as a sub-option of another :class:`_orm.Load` object. This method is used by the :meth:`_orm.Load.options` method.

def _clone_for_bind_strategy(self, attrs: Optional[Tuple[_AttrType, ...]], strategy: Optional[_StrategyKey], wildcard_key: Optional[_WildcardKeyType], opts: Optional[_OptsType] = None, attr_group: Optional[_AttrGroupType] = None, propagate_to_loaders: bool = True, reconcile_to_other: Optional[bool] = None) -> Self: (source)
def _process(self, compile_state: ORMCompileState, mapper_entities: Sequence[_MapperEntity], raiseerr: bool): (source)

implemented by subclasses

def _reconcile_query_entities_with_us(self, mapper_entities, raiseerr): (source)

called at process time to allow adjustment of the root entity inside of _LoadElement objects.

_cache_key_traversal = (source)

Undocumented