From: Mike Bayer Date: Fri, 9 May 2008 18:43:05 +0000 (+0000) Subject: identified case where pending upon commit() is needed; since attribute rollback funct... X-Git-Tag: rel_0_5beta1~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bbb0e9b572929c05c5c0b3b0e22ffdeda29ad59;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git identified case where pending upon commit() is needed; since attribute rollback functionality is gone its safe to revert to this --- diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 7ce825c9d7..848810c135 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -964,6 +964,7 @@ class InstanceState(object): """ self.committed_state = {} + self.pending = {} # unexpire attributes which have loaded if self.expired_attributes: diff --git a/test/orm/attributes.py b/test/orm/attributes.py index 3883cdcd1b..d31030f354 100644 --- a/test/orm/attributes.py +++ b/test/orm/attributes.py @@ -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):