]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug where list instrumentation would fail to represent a
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Aug 2013 17:27:27 +0000 (13:27 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Aug 2013 17:27:27 +0000 (13:27 -0400)
setslice of ``[0:0]`` correctly, which in particular could occur
when using ``insert(0, item)`` with the association proxy.  Due
to some quirk in Python collections, the issue was much more likely
with Python 3 rather than 2.  Also in 0.8.3, 0.7.11.
[ticket:2807]

doc/build/changelog/changelog_07.rst
doc/build/changelog/changelog_08.rst
doc/build/changelog/changelog_09.rst
lib/sqlalchemy/orm/collections.py
test/orm/test_collection.py

index c6da742b8decdb3d1d6a0271c251533fb17571f4..be1dd989132bd3c96a6342a139849b05965e2e0e 100644 (file)
@@ -6,6 +6,16 @@
 .. changelog::
     :version: 0.7.11
 
+    .. change::
+        :tags: bug, orm
+        :tickets: 2807
+
+        Fixed bug where list instrumentation would fail to represent a
+        setslice of ``[0:0]`` correctly, which in particular could occur
+        when using ``insert(0, item)`` with the association proxy.  Due
+        to some quirk in Python collections, the issue was much more likely
+        with Python 3 rather than 2.
+
     .. change::
         :tags: bug, sql
         :tickets: 2801
index c19fa22279efd49cd3f1ac8744ca2e4a98c95115..39a8627bad745d32338214b5795fa39a493cca7b 100644 (file)
@@ -6,6 +6,16 @@
 .. changelog::
     :version: 0.8.3
 
+    .. change::
+        :tags: bug, orm
+        :tickets: 2807
+
+        Fixed bug where list instrumentation would fail to represent a
+        setslice of ``[0:0]`` correctly, which in particular could occur
+        when using ``insert(0, item)`` with the association proxy.  Due
+        to some quirk in Python collections, the issue was much more likely
+        with Python 3 rather than 2.  Also in 0.7.11.
+
     .. change::
         :tags: bug, orm
         :tickets: 2779
index 3c38367f26a2319505789688ea0f1bcb0eeb8e7c..d928120f9b8bd4af5ce4514f601dafdffde558a5 100644 (file)
@@ -6,6 +6,16 @@
 .. changelog::
     :version: 0.9.0
 
+    .. change::
+        :tags: bug, orm
+        :tickets: 2807
+
+        Fixed bug where list instrumentation would fail to represent a
+        setslice of ``[0:0]`` correctly, which in particular could occur
+        when using ``insert(0, item)`` with the association proxy.  Due
+        to some quirk in Python collections, the issue was much more likely
+        with Python 3 rather than 2.  Also in 0.8.3, 0.7.11.
+
     .. change::
         :tags: bug, orm
         :tickets: 2794
index f8f4b958347c65f9c6a132f6c195d2e34685d666..6bd5ac968e06057f52bbdbfd99f14c9faeced3e3 100644 (file)
@@ -1075,7 +1075,10 @@ def _list_decorators():
                 start = index.start or 0
                 if start < 0:
                     start += len(self)
-                stop = index.stop or len(self)
+                if index.stop is not None:
+                    stop = index.stop
+                else:
+                    stop = len(self)
                 if stop < 0:
                     stop += len(self)
 
index 3a98da90fd4dc91a8131b232c2ed2cab672ef27c..4eb8b3fee7a98e198ef630ceb2145966486bb96b 100644 (file)
@@ -128,9 +128,9 @@ class CollectionsTest(fixtures.ORMTest):
         control = list()
 
         def assert_eq():
-            self.assert_(set(direct) == canary.data)
-            self.assert_(set(adapter) == canary.data)
-            self.assert_(direct == control)
+            eq_(set(direct), canary.data)
+            eq_(set(adapter), canary.data)
+            eq_(direct, control)
 
         # assume append() is available for list tests
         e = creator()
@@ -260,6 +260,11 @@ class CollectionsTest(fixtures.ORMTest):
             control[-2:-1] = values
             assert_eq()
 
+            values = [creator()]
+            direct[0:0] = values
+            control[0:0] = values
+            assert_eq()
+
 
         if hasattr(direct, '__delitem__') or hasattr(direct, '__delslice__'):
             for i in range(1, 4):