MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / LoaderCriteriaOption

Class LoaderCriteriaOption

lib/sqlalchemy/orm/util.py:1346–1522  ·  view source on GitHub ↗

Add additional WHERE criteria to the load for all occurrences of a particular entity. :class:`_orm.LoaderCriteriaOption` is invoked using the :func:`_orm.with_loader_criteria` function; see that function for details. .. versionadded:: 1.4

Source from the content-addressed store, hash-verified

1344
1345
1346class LoaderCriteriaOption(CriteriaOption):
1347 """Add additional WHERE criteria to the load for all occurrences of
1348 a particular entity.
1349
1350 :class:`_orm.LoaderCriteriaOption` is invoked using the
1351 :func:`_orm.with_loader_criteria` function; see that function for
1352 details.
1353
1354 .. versionadded:: 1.4
1355
1356 """
1357
1358 __slots__ = (
1359 "root_entity",
1360 "entity",
1361 "deferred_where_criteria",
1362 "where_criteria",
1363 "_where_crit_orig",
1364 "include_aliases",
1365 "propagate_to_loaders",
1366 )
1367
1368 _traverse_internals = [
1369 ("root_entity", visitors.ExtendedInternalTraversal.dp_plain_obj),
1370 ("entity", visitors.ExtendedInternalTraversal.dp_has_cache_key),
1371 ("where_criteria", visitors.InternalTraversal.dp_clauseelement),
1372 ("include_aliases", visitors.InternalTraversal.dp_boolean),
1373 ("propagate_to_loaders", visitors.InternalTraversal.dp_boolean),
1374 ]
1375
1376 root_entity: Optional[Type[Any]]
1377 entity: Optional[_InternalEntityType[Any]]
1378 where_criteria: Union[ColumnElement[bool], lambdas.DeferredLambdaElement]
1379 deferred_where_criteria: bool
1380 include_aliases: bool
1381 propagate_to_loaders: bool
1382
1383 _where_crit_orig: Any
1384
1385 def __init__(
1386 self,
1387 entity_or_base: _EntityType[Any],
1388 where_criteria: Union[
1389 _ColumnExpressionArgument[bool],
1390 Callable[[Any], _ColumnExpressionArgument[bool]],
1391 ],
1392 loader_only: bool = False,
1393 include_aliases: bool = False,
1394 propagate_to_loaders: bool = True,
1395 track_closure_variables: bool = True,
1396 ):
1397 entity = cast(
1398 "_InternalEntityType[Any]",
1399 inspection.inspect(entity_or_base, False),
1400 )
1401 if entity is None:
1402 self.root_entity = cast("Type[Any]", entity_or_base)
1403 self.entity = None

Callers 2

_unreduceMethod · 0.85
with_loader_criteriaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected