]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- repaired non-working attributes.set_committed_value function.
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Jun 2009 19:37:16 +0000 (19:37 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Jun 2009 19:37:16 +0000 (19:37 +0000)
CHANGES
lib/sqlalchemy/orm/attributes.py
test/orm/test_attributes.py

diff --git a/CHANGES b/CHANGES
index 1d986020a2a687ea5c98f8cf656c75c9864a4cab..4f814d4bcf624fb89df772808c775dda692cbdb8 100644 (file)
--- 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.
index 4fe562110d90aaf0764d437078d2dd01e119daa7..2c26f34f2a8f655876d7bc05d881cec64b7d46da 100644 (file)
@@ -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.
index 3b1b42dadcdf6334c27d2b0d328f79e2ef3b560f..ca8cef3ad85a72a77c2ddc5d760e2c53d0b77a1b 100644 (file)
@@ -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):