]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
.pop() on association proxies is no longer problematic with 0.4 collections.
authorJason Kirtland <jek@discorporate.us>
Wed, 18 Jul 2007 22:19:12 +0000 (22:19 +0000)
committerJason Kirtland <jek@discorporate.us>
Wed, 18 Jul 2007 22:19:12 +0000 (22:19 +0000)
lib/sqlalchemy/ext/associationproxy.py
test/ext/associationproxy.py

index b077a433a7f4c15bb6e636dc64ca1d1bb5cda190..0330a679f8b833f5fdf8a40867c0b554884832e1 100644 (file)
@@ -302,6 +302,9 @@ class _AssociationList(object):
     def insert(self, index, value):
         self.col[index:index] = [self._create(value)]
 
+    def pop(self, index=-1):
+        return self.getter(self.col.pop(index))
+
     def clear(self):
         del self.col[0:len(self.col)]
 
index 9b83830ca5f53dab8f3d1166dfcb0c09bffd00f4..3156e429237abc1e81c7523d014430704a55ea07 100644 (file)
@@ -138,6 +138,13 @@ class _CollectionOperations(PersistTest):
         self.assert_(len(p1._children) == 3)
         self.assert_(len(p1.children) == 3)
 
+        popped = p1.children.pop()
+        self.assert_(len(p1.children) == 2)
+        self.assert_(popped not in p1.children)
+        p1 = self.roundtrip(p1)
+        self.assert_(len(p1.children) == 2)
+        self.assert_(popped not in p1.children)
+
         p1.children[1] = 'changed-in-place'
         self.assert_(p1.children[1] == 'changed-in-place')
         inplace_id = p1._children[1].id
@@ -435,14 +442,7 @@ class SetTest(_CollectionOperations):
                         print 'want', repr(control)
                         print 'got', repr(p.children)
                         raise
-    
-    # workaround for bug #548
-    def test_set_pop(self):
-        Parent, Child = self.Parent, self.Child
-        p = Parent('p1')
-        p.children.add('a')
-        p.children.pop()
-        self.assert_(True)
+
 
 class CustomSetTest(SetTest):
     def __init__(self, *args, **kw):