The following demonstrates a python3 sqlalchemy bug where an association 
proxy does not allow assignment in place without specifying the start 
index.  It gives a "TypeError: list indices must be integers, not NoneType" 
error.  It fails on sqlalchemy 0.9.3, but python2 seems to have no problem.


from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import *
from sqlalchemy.ext.associationproxy import association_proxy


Base = declarative_base()


def build(value):
    return Table1(name=value)


class Table1(Base):
    __tablename__ = 'table1'

    id = Column(Integer, primary_key=True)
    name = Column(String(100))
    fk = Column(Integer, ForeignKey('table2.id'))


class Table2(Base):
    __tablename__ = 'table2'

    id = Column(Integer, primary_key=True)

    t1s = relationship('Table1')
    t1s_proxy = association_proxy('t1s', 'name', creator=build)


t2 = Table2()
t2.t1s.append(Table1(name='test'))

# fails
t2.t1s_proxy[:] = ['test']

# works
t2.t1s_proxy[0:] = ['test']

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to