summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/state.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-10-11 14:45:24 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-16 13:33:01 -0400
commit33119301bb3efa143ebaaef22a7b5170f14a1331 (patch)
tree3097d7db5f2defabad7792539a8048f3c95c5c0c /lib/sqlalchemy/orm/state.py
parent657ec85e8733c64b9be2154c3169d31c15a06dce (diff)
downloadsqlalchemy-33119301bb3efa143ebaaef22a7b5170f14a1331.tar.gz
Implement raiseload for deferred columns
Added "raiseload" feature for ORM mapped columns. As part of this change, the behavior of "deferred" is now more strict; an attribute that is set up as "deferred" at the mapper level no longer participates in an "unexpire" operation; that is, when an unexpire loads all the expired columns of an object which are not themselves in a deferred group, those which are mapper-level deferred will never be loaded. Deferral options set at query time should always be reset by an expiration operation. Renames deferred_scalar_loader to expired_attribute_loader Unfortunately we can't have raiseload() do this because it would break existing wildcard behavior. Fixes: #4826 Change-Id: I30d9a30236e0b69134e4094fb7c1ad2267f089d1
Diffstat (limited to 'lib/sqlalchemy/orm/state.py')
-rw-r--r--lib/sqlalchemy/orm/state.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py
index ead9bf2bb..c57af0784 100644
--- a/lib/sqlalchemy/orm/state.py
+++ b/lib/sqlalchemy/orm/state.py
@@ -593,11 +593,7 @@ class InstanceState(interfaces.InspectionAttrInfo):
del self.__dict__["parents"]
self.expired_attributes.update(
- [
- impl.key
- for impl in self.manager._loader_impls
- if impl.expire_missing or impl.key in dict_
- ]
+ [impl.key for impl in self.manager._loader_impls]
)
if self.callables:
@@ -671,8 +667,13 @@ class InstanceState(interfaces.InspectionAttrInfo):
return PASSIVE_NO_RESULT
toload = self.expired_attributes.intersection(self.unmodified)
+ toload = toload.difference(
+ attr
+ for attr in toload
+ if not self.manager[attr].impl.load_on_unexpire
+ )
- self.manager.deferred_scalar_loader(self, toload)
+ self.manager.expired_attribute_loader(self, toload)
# if the loader failed, or this
# instance state didn't have an identity,
@@ -719,11 +720,7 @@ class InstanceState(interfaces.InspectionAttrInfo):
was never populated or modified.
"""
- return self.unloaded.intersection(
- attr
- for attr in self.manager
- if self.manager[attr].impl.expire_missing
- )
+ return self.unloaded
@property
def _unloaded_non_object(self):