:param active_history=False:
When ``True``, indicates that the "previous" value for a
scalar attribute should be loaded when replaced, if not
- already loaded. Note that attributes generated by
- :func:`.composite` properties load the "previous" value
- in any case, however this is being changed in 0.7,
- so the flag is introduced here for forwards compatibility.
- (new in 0.6.6)
+ already loaded. See the same flag on :func:`.column_property`.
+ (This flag becomes meaningful specifically for
+ :func:`.composite` in 0.7 - previously it was a placeholder).
:param group:
A group name for this property when marked as deferred.
state.mutable_dict.pop(self.key)
def set(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
- if initiator and initiator.parent_token is self.parent_token:
- return
-
- if self.dispatch.on_set:
- old = self.get(state, dict_)
- value = self.fire_replace_event(state, dict_,
- value, old, initiator)
-
- state.modified_event(dict_, self, True, NEVER_SET)
- dict_[self.key] = value
+ ScalarAttributeImpl.set(self, state, dict_, value, initiator, passive)
state.mutable_dict[self.key] = value
compare_function=compare,
copy_function=copy,
mutable_scalars=True,
+ active_history=self.parent_property.active_history,
)
def create_row_processor(self, selectcontext, path, mapper,
@testing.resolve_artifact_names
def test_expire_attribute_set(self):
- """test one SELECT emitted when assigning to an expired
- mutable attribute - this will become 0 in 0.7.
+ """test no SELECT emitted when assigning to an expired
+ mutable attribute.
"""
assert 'data' not in f1.__dict__
def go():
f1.data = pickleable.Bar(10, 15)
- self.sql_count_(1, go)
+ self.sql_count_(0, go)
session.commit()
eq_(f1.data.x, 10)
@testing.resolve_artifact_names
def test_deferred_attribute_set(self):
- """test one SELECT emitted when assigning to a deferred
- mutable attribute - this will become 0 in 0.7.
+ """test no SELECT emitted when assigning to a deferred
+ mutable attribute.
"""
sa.orm.clear_mappers()
f1 = session.query(Foo).first()
def go():
f1.data = pickleable.Bar(10, 15)
- self.sql_count_(1, go)
+ self.sql_count_(0, go)
session.commit()
eq_(f1.data.x, 10)