diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-20 13:27:27 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-20 13:27:27 -0400 |
| commit | b13a434f6fb2a947b284f589148aa8cb6974e3d5 (patch) | |
| tree | 92e3b7e8b85bd36ec7d50d41b08c5cb22a614bce | |
| parent | 5b8e8598ab5c604d3ec20c0f6a3e6af06f879308 (diff) | |
| download | sqlalchemy-b13a434f6fb2a947b284f589148aa8cb6974e3d5.tar.gz | |
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.
[ticket:2807]
| -rw-r--r-- | doc/build/changelog/changelog_07.rst | 10 | ||||
| -rw-r--r-- | doc/build/changelog/changelog_08.rst | 10 | ||||
| -rw-r--r-- | doc/build/changelog/changelog_09.rst | 10 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/collections.py | 5 | ||||
| -rw-r--r-- | test/orm/test_collection.py | 11 |
5 files changed, 42 insertions, 4 deletions
diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst index c6da742b8..be1dd9891 100644 --- a/doc/build/changelog/changelog_07.rst +++ b/doc/build/changelog/changelog_07.rst @@ -7,6 +7,16 @@ :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 diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index c19fa2227..39a8627ba 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -8,6 +8,16 @@ .. 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 Backported a change from 0.9 whereby the iteration of a hierarchy diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 3c38367f2..d928120f9 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -8,6 +8,16 @@ .. 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 Fixed a potential issue in an ordered sequence implementation used diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index f8f4b9583..6bd5ac968 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -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) diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index 3a98da90f..4eb8b3fee 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -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): |
