summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-06-18 19:37:16 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-06-18 19:37:16 +0000
commitcea9cc5e8eb17e9ddee160bf5cfa29c438ef42df (patch)
tree9700f38cd0f6eb4a9760006014bd9327a0893918
parent8a72a5b0bc5fe5a276623e40499dede629391d1c (diff)
downloadsqlalchemy-cea9cc5e8eb17e9ddee160bf5cfa29c438ef42df.tar.gz
- repaired non-working attributes.set_committed_value function.
-rw-r--r--CHANGES2
-rw-r--r--lib/sqlalchemy/orm/attributes.py2
-rw-r--r--test/orm/test_attributes.py26
3 files changed, 29 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 1d986020a..4f814d4bc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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.
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 4fe562110..2c26f34f2 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -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.
diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py
index 3b1b42dad..ca8cef3ad 100644
--- a/test/orm/test_attributes.py
+++ b/test/orm/test_attributes.py
@@ -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):