Hi everyone! I'm puzzled by a behaviour shown by SA 0.6.5 that 0.5.8 didn't show, and I'm wondering what I'm doing wrong.. I have a simple uncascaded many-to-many relationship, and if I try the following:
1) save a child 2) close the session 3) associate the child to a parent and save the parent 4) deassociate the child and save the parent the association doesn't get removed from the junction table.. If I skip closing the session, it DOES get removed... Here's an example: from sqlalchemy import Column, String, Integer, Table, ForeignKey from sqlalchemy.engine import create_engine from sqlalchemy.orm import sessionmaker, relationship from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() junction = Table("junction", Base.metadata, Column("p_id", ForeignKey("parents.id")), Column("c_id", ForeignKey("children.id"))) class Child(Base): __tablename__ = "children" id = Column(Integer, primary_key=True) class Parent(Base): __tablename__ = "parents" id = Column(Integer, primary_key=True) children = relationship(Child, secondary=junction, cascade="") def save(session, x): session.add(x) session.flush() en = create_engine("sqlite:///:memory:", echo=True) Base.metadata.create_all(en) maker = sessionmaker(en) session = maker(autocommit=True) # Save a child and close the session c = Child() save(session, c) session.close() # Associate the child to a parent and save p = Parent() p.children = [c] save(session, p) # Try to remove the child p.children = [] save(session, p) I'd expect that the last command would log something like BEGIN (implicit) SELECT children.id AS children_id FROM children WHERE children.id = ? (1,) DELETE FROM junction WHERE junction.p_id = ? AND junction.c_id = ? (1, 1) COMMIT SELECT parents.id AS parents_id FROM parents WHERE parents.id = ? (1,) but instead I get only BEGIN (implicit) COMMIT SELECT parents.id AS parents_id FROM parents WHERE parents.id = ? (1,) This used to work with 0.5.8, what am I doing wrong? Many thanks for your attention! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.