From 71c13990aa1ea7af8777aae4a2a26d3f6d6e8a0a Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Tue, 2 Feb 2021 20:49:41 +0100 Subject: Improve noload documentation Also add a link to the loading strategies doc from the async orm docs Fixes: #5832 Change-Id: I41170369273df7d323f7140cd05759567484dc4d --- lib/sqlalchemy/orm/strategy_options.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index fbecfedeb..f24f42a6b 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -1341,12 +1341,20 @@ def immediateload(*keys): def noload(loadopt, attr): """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-chained and standalone operation. :func:`_orm.noload` applies to :func:`_orm.relationship` attributes; for column-based attributes, see :func:`_orm.defer`. + .. note:: Setting this loading strategy as the default strategy + for a relationship using the :paramref:`.orm.relationship.lazy` + parameter may cause issues with flushes, such if a delete operation + needs to load related objects and instead ``None`` was returned. + .. seealso:: :ref:`loading_toplevel` -- cgit v1.2.1