summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.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/attributes.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/attributes.py')
-rw-r--r--lib/sqlalchemy/orm/attributes.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 1466f5f47..83069f113 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -468,7 +468,7 @@ class AttributeImpl(object):
compare_function=None,
active_history=False,
parent_token=None,
- expire_missing=True,
+ load_on_unexpire=True,
send_modified_events=True,
accepts_scalar_loader=None,
**kwargs
@@ -503,10 +503,13 @@ class AttributeImpl(object):
Allows multiple AttributeImpls to all match a single
owner attribute.
- :param expire_missing:
- if False, don't add an "expiry" callable to this attribute
- during state.expire_attributes(None), if no value is present
- for this key.
+ :param load_on_unexpire:
+ if False, don't include this attribute in a load-on-expired
+ operation, i.e. the "expired_attribute_loader" process.
+ The attribute can still be in the "expired" list and be
+ considered to be "expired". Previously, this flag was called
+ "expire_missing" and is only used by a deferred column
+ attribute.
:param send_modified_events:
if False, the InstanceState._modified_event method will have no
@@ -534,7 +537,7 @@ class AttributeImpl(object):
if active_history:
self.dispatch._active_history = True
- self.expire_missing = expire_missing
+ self.load_on_unexpire = load_on_unexpire
self._modified_token = Event(self, OP_MODIFIED)
__slots__ = (
@@ -546,7 +549,7 @@ class AttributeImpl(object):
"parent_token",
"send_modified_events",
"is_equal",
- "expire_missing",
+ "load_on_unexpire",
"_modified_token",
"accepts_scalar_loader",
)
@@ -683,6 +686,7 @@ class AttributeImpl(object):
if (
self.accepts_scalar_loader
+ and self.load_on_unexpire
and key in state.expired_attributes
):
value = state._load_expired(state, passive)