]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Improve ORM loader strategy error messages to use user-friendly representations
authorJan Vollmer <jan@vllmr.dev>
Wed, 15 Jul 2026 12:56:19 +0000 (08:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 20 Jul 2026 14:11:03 +0000 (10:11 -0400)
commitada9d7fcd18d10ff101bf2e3b57e32bb06301605
tree764a9bb6430e39c343e3eb7244364a38de80fdcb
parent06fd857c553a9e9cc7b4f30d179ee7582655e7e7
Improve ORM loader strategy error messages to use user-friendly representations

Improved error messages raised when ORM loader strategy options cannot be
applied to a query.  Messages now render the offending option in a
user-friendly form such as ``joinedload(User.orders)`` rather than exposing
internal class and path representations, and the "does not apply to root
entities" message now includes the option that triggered the error.  The
same user-friendly rendering is also applied to the "conflicting loader
strategy" message and to the ``of_type()`` representation in "does not
link" messages.  Originating pull request courtesy Jan Vollmer.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #12398
Closes: #12401
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12401
Pull-request-sha: 4de2e161924d2d61ee7ad8402315da754e7995f4

Change-Id: I41c4f7fd077bd7fdb6e6ac9675370a37f7e7d7b4
13 files changed:
doc/build/changelog/unreleased_21/12398.rst [new file with mode: 0644]
lib/sqlalchemy/orm/_typing.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/orm/util.py
test/orm/test_deferred.py
test/orm/test_eager_relations.py
test/orm/test_expire.py
test/orm/test_options.py
test/orm/test_utils.py