]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Use the shallowest path when an object is loaded at multiple paths main
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 Aug 2026 21:43:13 +0000 (17:43 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 13 Aug 2026 22:07:18 +0000 (18:07 -0400)
commit111a05a35b9fb4e6683bd18d3064634e002233f6
treeaf22658b70b3ee81d7a42d13ebcfd93e919db809
parentabd177230f2c6a8166e07c71010e8e27004b9740
Use the shallowest path when an object is loaded at multiple paths

Fixed long-standing issue where an object that was loaded at more than
one path within a single query, such as when a chain of joinedload()
options leads back to an entity that was also loaded at the top level of
the query, would retain the loader options of whichever path the query
happened to see last, which varied with the loader strategy in use.  The
options an object retains are applied to all forms of lazy loading for
that object, so an otherwise identical set of options could behave
differently depending on the loader strategy.  The shallowest path is
now favored, which is deterministic.

Fixes: #13507
Change-Id: I438e6655a9ecf59ca554312a7a87c8b85b4879d2
doc/build/changelog/migration_21.rst
doc/build/changelog/unreleased_21/13507.rst [new file with mode: 0644]
lib/sqlalchemy/orm/loading.py
test/orm/test_loading.py