mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-06 07:45:30 -04:00
- repaired non-working attributes.set_committed_value function.
This commit is contained in:
@@ -45,6 +45,8 @@ CHANGES
|
||||
columns, has been enhanced such that the fk->itself aspect of the
|
||||
relation won't be used to determine relation direction.
|
||||
|
||||
- repaired non-working attributes.set_committed_value function.
|
||||
|
||||
- Trimmed the pickle format for InstanceState which should further
|
||||
reduce the memory footprint of pickled instances. The format
|
||||
should be backwards compatible with that of 0.5.4 and previous.
|
||||
|
||||
@@ -1418,7 +1418,7 @@ def set_committed_value(instance, key, value):
|
||||
|
||||
"""
|
||||
state, dict_ = instance_state(instance), instance_dict(instance)
|
||||
state.get_impl(key).set_committed_value(state, dict_, key, value)
|
||||
state.get_impl(key).set_committed_value(state, dict_, value)
|
||||
|
||||
def set_attribute(instance, key, value):
|
||||
"""Set the value of an attribute, firing history events.
|
||||
|
||||
@@ -512,6 +512,32 @@ class AttributesTest(_base.ORMTest):
|
||||
except sa_exc.ArgumentError, e:
|
||||
assert False
|
||||
|
||||
class UtilTest(_base.ORMTest):
|
||||
def test_helpers(self):
|
||||
class Foo(object):
|
||||
pass
|
||||
|
||||
class Bar(object):
|
||||
pass
|
||||
|
||||
attributes.register_class(Foo)
|
||||
attributes.register_class(Bar)
|
||||
attributes.register_attribute(Foo, "coll", uselist=True, useobject=True)
|
||||
|
||||
f1 = Foo()
|
||||
b1 = Bar()
|
||||
b2 = Bar()
|
||||
coll = attributes.init_collection(f1, "coll")
|
||||
assert coll.data is f1.coll
|
||||
assert attributes.get_attribute(f1, "coll") is f1.coll
|
||||
attributes.set_attribute(f1, "coll", [b1])
|
||||
assert f1.coll == [b1]
|
||||
eq_(attributes.get_history(f1, "coll"), ([b1], [], []))
|
||||
attributes.set_committed_value(f1, "coll", [b2])
|
||||
eq_(attributes.get_history(f1, "coll"), ((), [b2], ()))
|
||||
|
||||
attributes.del_attribute(f1, "coll")
|
||||
assert "coll" not in f1.__dict__
|
||||
|
||||
class BackrefTest(_base.ORMTest):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user