MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / immediateload

Method immediateload

lib/sqlalchemy/orm/strategy_options.py:436–483  ·  view source on GitHub ↗

Indicate that the given attribute should be loaded using an immediate load with a per-attribute SELECT statement. The load is achieved using the "lazyloader" strategy and does not fire off any additional eager loaders. The :func:`.immediateload` option is superseded

(
        self,
        attr: _AttrType,
        recursion_depth: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

434 return self._set_relationship_strategy(attr, {"lazy": "select"})
435
436 def immediateload(
437 self,
438 attr: _AttrType,
439 recursion_depth: Optional[int] = None,
440 ) -> Self:
441 """Indicate that the given attribute should be loaded using
442 an immediate load with a per-attribute SELECT statement.
443
444 The load is achieved using the "lazyloader" strategy and does not
445 fire off any additional eager loaders.
446
447 The :func:`.immediateload` option is superseded in general
448 by the :func:`.selectinload` option, which performs the same task
449 more efficiently by emitting a SELECT for all loaded objects.
450
451 This function is part of the :class:`_orm.Load` interface and supports
452 both method-chained and standalone operation.
453
454 :param recursion_depth: optional int; when set to a positive integer
455 in conjunction with a self-referential relationship,
456 indicates "selectin" loading will continue that many levels deep
457 automatically until no items are found.
458
459 .. note:: The :paramref:`_orm.immediateload.recursion_depth` option
460 currently supports only self-referential relationships. There
461 is not yet an option to automatically traverse recursive structures
462 with more than one relationship involved.
463
464 .. warning:: This parameter is new and experimental and should be
465 treated as "alpha" status
466
467 .. versionadded:: 2.0 added
468 :paramref:`_orm.immediateload.recursion_depth`
469
470
471 .. seealso::
472
473 :ref:`loading_toplevel`
474
475 :ref:`selectin_eager_loading`
476
477 """
478 loader = self._set_relationship_strategy(
479 attr,
480 {"lazy": "immediate"},
481 opts={"recursion_depth": recursion_depth},
482 )
483 return loader
484
485 @util.deprecated(
486 "2.1",

Callers 3

load_options_okFunction · 0.80
load_options_errorFunction · 0.80
test_all_loadMethod · 0.80

Calls 1

Tested by 1

test_all_loadMethod · 0.64