On Jan 9, 2014, at 10:31 AM, Russell Holloway <russ.d.hollo...@gmail.com> wrote:
> > OK so, you have: > > Page.user_relationships -> collection of PageToUser > > PageToUser -> single User > > then, you are saying : > > some_page.user_relationships = [] > session.flush() > > What SQL would you expect this to produce? After a flush, what would the > rows in your page_to_user table look like? > > > I would expect it to delete entries, resulting in no rows for that page_id > DELETE FROM Page_To_User WHERE page_id = ? > > Perhaps it tries this instead? > UPDATE Page_To_User SET page_id = NULL WHERE page_id = ? You are correct in both cases. So if you follow the instructions for delete-orphan cascade as previously mentioned here: http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#configuring-delete-delete-orphan-cascade the rows will be deleted instead. Perhaps you’re being thrown off by the fact that an ORM level cascade is set on the *opposite* side as a FOREIGN KEY cascade in SQL, but that is how it works. The Page.user_relationships collection is what indicates the handling of PageToUser objects. If you want to see the origin of the “CASCADE” settings, they come from Hibernate: http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/example-parentchild.html .
signature.asc
Description: Message signed with OpenPGP using GPGMail