[sqlalchemy] Deleting all rows in secondary table when object is deleted?

2012-06-25 Thread Gerald Thibault
I have a m2m relationship of Posts and Categories. A post can be in any number of categories, and a category can have any number of posts. This relation is defined on the Post model: categories = relation(Category, lazy=True, secondary=PostCategory.__table__,

Re: [sqlalchemy] Deleting all rows in secondary table when object is deleted?

2012-06-25 Thread Michael Bayer
this question is arising with unusual frequency in recent weeks, which suggests a shortcoming in the docs. Rather than answering here, I've added what is hopefully a comprehensive answer to the documentation; it would be helpful if you could confirm for me that it answers your question, or if

Re: [sqlalchemy] Deleting all rows in secondary table when object is deleted?

2012-06-25 Thread Gerald Thibault
The documentation is fine, I just get lost in it sometimes because there is so much, and I have a hard time tracking down the specific thing I'm looking for. It turns out I was just overcomplicating things. Once I removed 'cascade' from the ref, everything works as expected. Had I just left

Re: [sqlalchemy] Deleting all rows in secondary table when object is deleted?

2012-06-25 Thread Michael Bayer
well dont worry, that doc is new as of an hour ago, and I dont think that behavior is actually explained anywhere; historically, people tend to not worry about it and it just happens, though there have been stackoverflow questions about it lately. it's better that it's described. On Jun 25,