]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
identified case where pending upon commit() is needed; since attribute rollback funct...
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 9 May 2008 18:43:05 +0000 (18:43 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 9 May 2008 18:43:05 +0000 (18:43 +0000)
lib/sqlalchemy/orm/attributes.py
test/orm/attributes.py

index 7ce825c9d759d3e21ccb0dfc72bcd9db82cf6950..848810c135379f91911815f9fbb74199efcddbd7 100644 (file)
@@ -964,6 +964,7 @@ class InstanceState(object):
         
         """
         self.committed_state = {}
+        self.pending = {}
         
         # unexpire attributes which have loaded
         if self.expired_attributes:
index 3883cdcd1b0a285868d30b8307a4f4007249a5e2..d31030f3547674279e821567e0c3a8e65de8a6e3 100644 (file)
@@ -669,7 +669,20 @@ class PendingBackrefTest(TestBase):
 
         called[0] = 0
         lazy_load = (p1, p2, p3) = [Post("post 1"), Post("post 2"), Post("post 3")]
+    
+    def test_commit_removes_pending(self):
+        global lazy_load
+        lazy_load = (p1, ) = [Post("post 1"), ]
+        called[0] = 0
 
+        b = Blog("blog 1")
+        p1.blog = b
+        attributes.instance_state(b).commit_all()
+        attributes.instance_state(p1).commit_all()
+        assert b.posts == [Post("post 1")]
+        
+        
+        
 class HistoryTest(TestBase):
     def test_get_committed_value(self):
         class Foo(fixtures.Base):