[Sqlalchemy-tickets] [sqlalchemy] #2807: incorrect logic in collection setitem for slice
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-20 14:26:31
|
#2807: incorrect logic in collection setitem for slice
---------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: highest | Milestone: 0.7.xx
Component: orm | Severity: minor - half an hour
Keywords: | Progress State: on hold
---------------------+---------------------------------------
{{{
diff --git a/lib/sqlalchemy/orm/collections.py
b/lib/sqlalchemy/orm/collections.py
index f8f4b95..54a79f7 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -1075,7 +1075,7 @@ def _list_decorators():
start = index.start or 0
if start < 0:
start += len(self)
- stop = index.stop or len(self)
+ stop = index.stop if index.stop is not None else
len(self)
if stop < 0:
stop += len(self)
}}}
current test case, only occurs on py3k. for some reason py2k isn't taking
us there (maybe the zeroes?):
{{{
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
bs = relationship("B")
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey('a.id'))
a1 = A()
b1, b2 = B(), B()
a1.bs = [b2]
a1.bs[0:0] = [b1]
assert a1.bs == [b1, b2]
}}}
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2807>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|