From e7e09649761cfb4afc242c541ab403258e75edd5 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 27 Apr 2023 16:48:25 -0400 Subject: improve natural_path usage in two places Fixed loader strategy pathing issues where eager loaders such as :func:`_orm.joinedload` / :func:`_orm.selectinload` would fail to traverse fully for many-levels deep following a load that had a :func:`_orm.with_polymorphic` or similar construct as an interim member. Here we can take advantage of 2.0's refactoring of strategy_options to identify the "chop_path" concept can be simplified to work with "natural" paths alone. In addition, identified existing logic in PropRegistry that works fine, but needed the "is_unnatural" attribute to be more accurate for a given path, so we set that up front to True if the ancestor is_unnatural. Fixes: #9715 Change-Id: Ie6b3f55b6a23d0d32628afd22437094263745114 --- lib/sqlalchemy/orm/strategies.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/sqlalchemy/orm/strategies.py') diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 5581e5c7f..8e06c4f59 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -1063,6 +1063,7 @@ class LazyLoader( if extra_options: stmt._with_options += extra_options + stmt._compile_options += {"_current_path": effective_path} if use_get: -- cgit v1.2.1