diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-06-26 13:24:22 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-06-26 13:49:49 -0400 |
commit | 9ac0f8119e34a696fbf711e00262e9c0851b749c (patch) | |
tree | f05beb1e57e70d4e286ac8b068f992f4fb52b59c /lib/sqlalchemy/orm/attributes.py | |
parent | e04594339c19c3cd8b8e0d96ce83e5ded961dbb7 (diff) | |
download | sqlalchemy-9ac0f8119e34a696fbf711e00262e9c0851b749c.tar.gz |
Support state expiration for with_expression(); rename deferred_expression
The attributeimpl for a deferred_expression does not
support a scalar loader, add new configurability so that
the impl can have this flag turned off. Document
that the with_expression() system currently does not
offer any deferred loading.
To eliminate confusion over "deferred", which refers to
lazy loading of column attributes, and "with_expression",
which refers to an attribute that is explicitly at
query time only, rename deferred_expression to query_expression.
Change-Id: I07c4a050ed68c79ccbde9492e9de1630b7470d74
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index f3a5c4735..01cb0056e 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -388,7 +388,7 @@ class AttributeImpl(object): callable_, dispatch, trackparent=False, extension=None, compare_function=None, active_history=False, parent_token=None, expire_missing=True, - send_modified_events=True, + send_modified_events=True, accepts_scalar_loader=None, **kwargs): r"""Construct an AttributeImpl. @@ -449,6 +449,11 @@ class AttributeImpl(object): else: self.is_equal = compare_function + if accepts_scalar_loader is not None: + self.accepts_scalar_loader = accepts_scalar_loader + else: + self.accepts_scalar_loader = self.default_accepts_scalar_loader + # TODO: pass in the manager here # instead of doing a lookup attr = manager_of_class(class_)[key] @@ -465,7 +470,7 @@ class AttributeImpl(object): __slots__ = ( 'class_', 'key', 'callable_', 'dispatch', 'trackparent', 'parent_token', 'send_modified_events', 'is_equal', 'expire_missing', - '_modified_token' + '_modified_token', 'accepts_scalar_loader' ) def _init_modified_token(self): @@ -657,7 +662,7 @@ class AttributeImpl(object): class ScalarAttributeImpl(AttributeImpl): """represents a scalar value-holding InstrumentedAttribute.""" - accepts_scalar_loader = True + default_accepts_scalar_loader = True uses_objects = False supports_population = True collection = False @@ -743,7 +748,7 @@ class ScalarObjectAttributeImpl(ScalarAttributeImpl): """ - accepts_scalar_loader = False + default_accepts_scalar_loader = False uses_objects = True supports_population = True collection = False @@ -867,7 +872,7 @@ class CollectionAttributeImpl(AttributeImpl): semantics to the orm layer independent of the user data implementation. """ - accepts_scalar_loader = False + default_accepts_scalar_loader = False uses_objects = True supports_population = True collection = True |