]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixed attributes bug where if an object is committed, its lazy-loaded list got
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Mar 2006 16:56:05 +0000 (16:56 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 14 Mar 2006 16:56:05 +0000 (16:56 +0000)
blown away if it hadnt been loaded

CHANGES
lib/sqlalchemy/attributes.py
test/objectstore.py

diff --git a/CHANGES b/CHANGES
index 6d73ccaba99f4e752ddc2ba81af79d98ff2b7628..3ac27f1999df14164aeeddfdfe45e42166dcfbc3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+0.1.5
+- fixed attributes bug where if an object is committed, its lazy-loaded list got 
+blown away if it hadnt been loaded
+
 0.1.4
 - create_engine() now uses genericized parameters; host/hostname, db/dbname/database, 
 password/passwd, etc. for all engine connections. makes engine URIs much more "universal"
index a41cdac9dfa5a62729e3cea4c815fb745fae07c8..b03ead1c2ebf3d845f71efe1167b2eaf00be2780 100644 (file)
@@ -214,7 +214,7 @@ class CallableProp(object):
                 value = None
             p = self.manager.create_list(self.obj, self.key, value, readonly=self.live, **self.kwargs)
         
-        if not self.live:
+        if not self.live and not passive:
             # set the new history list as the new attribute, discards ourself
             self.manager.attribute_history(self.obj)[self.key] = p
             self.manager = None
index 312e1b53f12c31a30316e7fcfb2e124acb4127e8..6a3a16f7786c522d4ffea2c098bba447663f9044 100644 (file)
@@ -386,6 +386,26 @@ class SaveTest(AssertMixin):
         self.assert_(u.user_id == userlist[0].user_id and userlist[0].user_name == 'modifiedname')
         self.assert_(u2.user_id == userlist[1].user_id and userlist[1].user_name == 'savetester2')
 
+    def testlazyattrcommit(self):
+        """tests that when a lazy-loaded list is unloaded, and a commit occurs, that the
+        'passive' call on that list does not blow away its value"""
+        m1 = mapper(User, users, properties = {
+            'addresses': relation(mapper(Address, addresses))
+        })
+        
+        u = User()
+        u.addresses.append(Address())
+        u.addresses.append(Address())
+        u.addresses.append(Address())
+        u.addresses.append(Address())
+        objectstore.commit()
+        objectstore.clear()
+        ulist = m1.select()
+        u1 = ulist[0]
+        u1.user_name = 'newname'
+        objectstore.commit()
+        self.assert_(len(u1.addresses) == 4)
+        
     def testinherits(self):
         m1 = mapper(User, users)