MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / noload

Method noload

lib/sqlalchemy/orm/strategy_options.py:478–502  ·  view source on GitHub ↗

Indicate that the given relationship attribute should remain unloaded. The relationship attribute will return ``None`` when accessed without producing any loading effect. This function is part of the :class:`_orm.Load` interface and supports both method-chai

(self, attr: _AttrType)

Source from the content-addressed store, hash-verified

476 return loader
477
478 def noload(self, attr: _AttrType) -> Self:
479 """Indicate that the given relationship attribute should remain
480 unloaded.
481
482 The relationship attribute will return ``None`` when accessed without
483 producing any loading effect.
484
485 This function is part of the :class:`_orm.Load` interface and supports
486 both method-chained and standalone operation.
487
488 :func:`_orm.noload` applies to :func:`_orm.relationship` attributes
489 only.
490
491 .. legacy:: The :func:`_orm.noload` option is **legacy**. As it
492 forces collections to be empty, which invariably leads to
493 non-intuitive and difficult to predict results. There are no
494 legitimate uses for this option in modern SQLAlchemy.
495
496 .. seealso::
497
498 :ref:`loading_toplevel`
499
500 """
501
502 return self._set_relationship_strategy(attr, {"lazy": "noload"})
503
504 def raiseload(self, attr: _AttrType, sql_only: bool = False) -> Self:
505 """Indicate that the given attribute should raise an error if accessed.

Callers 4

load_options_okFunction · 0.80
load_options_errorFunction · 0.80
goMethod · 0.80

Calls 1

Tested by 2

goMethod · 0.64