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/strategies.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/strategies.py')
-rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 4e7636cf8..4b9eb3b0f 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -195,7 +195,7 @@ class ColumnLoader(LoaderStrategy): @log.class_logger -@properties.ColumnProperty.strategy_for(deferred_expression=True) +@properties.ColumnProperty.strategy_for(query_expression=True) class ExpressionColumnLoader(ColumnLoader): def __init__(self, parent, strategy_key): super(ExpressionColumnLoader, self).__init__(parent, strategy_key) @@ -235,6 +235,15 @@ class ExpressionColumnLoader(ColumnLoader): else: populators["expire"].append((self.key, True)) + def init_class_attribute(self, mapper): + self.is_class_level = True + + _register_attribute( + self.parent_property, mapper, useobject=False, + compare_function=self.columns[0].type.compare_values, + accepts_scalar_loader=False + ) + @log.class_logger @properties.ColumnProperty.strategy_for(deferred=True, instrument=True) |