Hello all, In regards to ordering_list: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/orderinglist.html
from sqlalchemy.ext.orderinglist import ordering_list Base = declarative_base() class Slide(Base): __tablename__ = 'slide' id = Column(Integer, primary_key=True) name = Column(String) bullets = relationship("Bullet", order_by="Bullet.position", collection_class=ordering_list('position')) class Bullet(Base): __tablename__ = 'bullet' id = Column(Integer, primary_key=True) slide_id = Column(Integer, ForeignKey('slide.id')) position = Column(Integer) text = Column(String) If we added a `backref` to 'bullets' relationship (i.e. `slide`) so the following were possible: slide = Slide(...) assert len(slide.bullets) == 0 session.add(slide) bullet0 = Bullet(...) session.add(bullet0) bullet0.slide = slide session.commit() assert len(slide.bullets) == 1 print bullet0.position # <<<<< position is None ??? bullet1 = Bullet(...) session.add(bullet1) slide.bullets.append(bullet1) session.commit() assert len(slide.bullets) == 2 assert bullet0.position = 0 # <<<<< position is correct now assert bullet1.position = 1 Should `bullet.position` receive a value `0` since it's the 1st one added even when the relationship assignment happens from the MANYTOONE side? It seems like `bullet` position remains `None` until items are added to the `bullets` collection. Although I have not test it using `test/ext/test_orderinglist.py`, the depicted "position=None" behavior occurs in our own model. Thoughts? Thanks in advance -- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.