Consider the following model: class Comment(object): def __init__(self, text): self.text = text
CommentTable=Table('Comment', metadata, Column('id', Integer, primary_key=True), Column('text', Unicode(512)), ) CommentMapper = mapper(Comment, CommentTable ) class Image(object): def __init__(self, name): self.name = name ImageTable = Table("Image", metadata, Column('id', Integer, primary_key=True), Column('name', Unicode(128)), ) #relationship between Images and Comments ImageCommentTable = Table("ImageComment", metadata, Column("imageID", Integer, ForeignKey("Image.id"), primary_key=True), Column("commentID", Integer, ForeignKey("Comment.id"), primary_key=True), ) class ImageComment(object): pass mapper(ImageComment, ImageCommentTable, properties ={ 'comments':relation(Comment, lazy=False, cascade="all") }) imageMapper = mapper(Image, ImageTable, properties={'comments': relation(Comment, secondary=ImageCommentTable, lazy=False)} ) and the following code: i = Image("new") session.save(i) session.flush() c = Comment("new comment") session.save(c) session.flush() i.comments.append(c) session.save(i) session.flush() OK, so that should make an entry in all three tables. Now, I want to remove the comment: c = session.query(Comment).get(c.id) session.delete(c) session.flush() session.clear() Now, if you run the sqlcomment: "select * from imagecomment" you still see the relationship to the comment that is no longer there. Perhaps I do not understand cascade properly, but "delete-orphan" causes a problem on object creation. help? -chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---