mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-22 16:41:25 -04:00
- Fixed bug in association proxy where assigning an empty slice
(e.g. ``x[:] = [...]``) would fail on Py3k.
This commit is contained in:
Vendored
+6
@@ -14,6 +14,12 @@
|
||||
.. changelog::
|
||||
:version: 0.9.4
|
||||
|
||||
.. change::
|
||||
:tags: bug, ext, py3k
|
||||
|
||||
Fixed bug in association proxy where assigning an empty slice
|
||||
(e.g. ``x[:] = [...]``) would fail on Py3k.
|
||||
|
||||
.. change::
|
||||
:tags: bug, general
|
||||
:tickets: 2979
|
||||
|
||||
@@ -540,11 +540,12 @@ class _AssociationList(_AssociationCollection):
|
||||
stop = index.stop
|
||||
step = index.step or 1
|
||||
|
||||
start = index.start or 0
|
||||
rng = list(range(index.start or 0, stop, step))
|
||||
if step == 1:
|
||||
for i in rng:
|
||||
del self[index.start]
|
||||
i = index.start
|
||||
del self[start]
|
||||
i = start
|
||||
for item in value:
|
||||
self.insert(i, item)
|
||||
i += 1
|
||||
|
||||
@@ -212,6 +212,13 @@ class _CollectionOperations(fixtures.TestBase):
|
||||
self.assert_(p1.children == after)
|
||||
self.assert_([c.name for c in p1._children] == after)
|
||||
|
||||
p1.children[:] = ['d', 'e']
|
||||
after = ['d', 'e']
|
||||
self.assert_(p1.children == after)
|
||||
self.assert_([c.name for c in p1._children] == after)
|
||||
|
||||
p1.children[:] = ['a', 'b']
|
||||
|
||||
p1.children += ['c']
|
||||
after = ['a', 'b', 'c']
|
||||
self.assert_(p1.children == after)
|
||||
|
||||
Reference in New Issue
Block a user