On Jun 6, 2011, at 6:11 PM, Geoff wrote:

> I've searched for an answer to this but can't find one but I did find
> an old archived e-mail discussing this which refers to ticket #249.
> 
> I have two tables in a many-many relationship. I do not want deletes
> to cascade between these two tables but I do want any delete to
> cascade to the secondary table in order to prevent the secondary table
> having rows that point to nowhere.
> 
> A recent check on my (sqlite) database shows that SQLAlchemy does not
> do this automatically but the discussion I found seems to indicate
> that this should happen. Is it possible that this is a regression? Or
> maybe I used be doing something that I'm not?

The table referenced by "secondary=" in a relationship() is managed entirely, 
regardless of cascade setting, but only from the perspective of the parent.  
Meaning if A references a collection of B, the row in a_to_b will be deleted if 
you 1. delete A, or 2. remove a B from A's collection.   Deleting a B by itself 
as in session.delete(B) won't have an effect unless you apply a backref to the 
relationship so that each B also knows about its collection of  A.


-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to