From 1c3efa4bc79f5277231239394d96481f14ff0e58 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 13 Jun 2024 10:04:01 -0400 Subject: [PATCH] strongly discourage noload Change-Id: I54a1c1d29b33091838b7f3fcd46eeec48bbd498b --- doc/build/orm/queryguide/relationships.rst | 3 +-- lib/sqlalchemy/orm/strategy_options.py | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/build/orm/queryguide/relationships.rst b/doc/build/orm/queryguide/relationships.rst index 30c8b1906f..bf6f692b98 100644 --- a/doc/build/orm/queryguide/relationships.rst +++ b/doc/build/orm/queryguide/relationships.rst @@ -1001,8 +1001,7 @@ Wildcard Loading Strategies --------------------------- Each of :func:`_orm.joinedload`, :func:`.subqueryload`, :func:`.lazyload`, -:func:`.selectinload`, -:func:`.noload`, and :func:`.raiseload` can be used to set the default +:func:`.selectinload`, and :func:`.raiseload` can be used to set the default style of :func:`_orm.relationship` loading for a particular query, affecting all :func:`_orm.relationship` -mapped attributes not otherwise diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index 8d691aa20c..f4b0bb9a96 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -507,10 +507,10 @@ class _AbstractLoad(traversals.GenerativeOnTraversal, LoaderOption): :func:`_orm.noload` applies to :func:`_orm.relationship` attributes only. - .. 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. + .. legacy:: The :func:`_orm.noload` option is **legacy**. As it + forces collections to be empty, which invariably leads to + non-intuitive and difficult to predict results. There are no + legitimate uses for this option in modern SQLAlchemy. .. seealso:: -- 2.47.2