diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-26 18:50:05 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-08-23 12:46:41 -0400 |
| commit | 2fc7078a08db057ea7e43991205aaee5562d7fd3 (patch) | |
| tree | fb4f227072d50d8e493b988832fc0b4c2771664b /lib/sqlalchemy/orm/state.py | |
| parent | e429ef1d31343b99e885f58a79800ae490155294 (diff) | |
| download | sqlalchemy-2fc7078a08db057ea7e43991205aaee5562d7fd3.tar.gz | |
Run eager loaders on unexpire
Eager loaders, such as joined loading, SELECT IN loading, etc., when
configured on a mapper or via query options will now be invoked during
the refresh on an expired object; in the case of selectinload and
subqueryload, since the additional load is for a single object only,
the "immediateload" scheme is used in these cases which resembles the
single-parent query emitted by lazy loading.
Change-Id: I7ca2c77bff58dc21015d60093a88c387937376b2
Fixes: #1763
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
| -rw-r--r-- | lib/sqlalchemy/orm/state.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index f6c06acc8..ead9bf2bb 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -595,12 +595,23 @@ class InstanceState(interfaces.InspectionAttrInfo): self.expired_attributes.update( [ impl.key - for impl in self.manager._scalar_loader_impls + for impl in self.manager._loader_impls if impl.expire_missing or impl.key in dict_ ] ) if self.callables: + # the per state loader callables we can remove here are + # LoadDeferredColumns, which undefers a column at the instance + # level that is mapped with deferred, and LoadLazyAttribute, + # which lazy loads a relationship at the instance level that + # is mapped with "noload" or perhaps "immediateload". + # Before 1.4, only column-based + # attributes could be considered to be "expired", so here they + # were the only ones "unexpired", which means to make them deferred + # again. For the moment, as of 1.4 we also apply the same + # treatment relationships now, that is, an instance level lazy + # loader is reset in the same way as a column loader. for k in self.expired_attributes.intersection(self.callables): del self.callables[k] |
