On Sep 28, 12:06 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> I dont really see how you could get this exact SQL out of the session,  
> since its literally attempting to delete the same orange object twice,  
> which should be impossible.   I thought you meant that your MySQL  
> database has ON DELETE CASCADE configured - is the first "DELETE FROM  
> orange" above representing the ON DELETE CASCADE activity ?

No, because the code is session.delete()ing oranges, not apples.
MySQL does have cascades configured correctly.

> Assuming so, you would need to ensure that the apple->orange->banana  
> relations are configured such that they work correctly in conjunction  
> with ON DELETE CASCADE.  This basically means to set  
> "passive_deletes=True" so that no SELECT is issued to load in rows  
> that may require deletion.  Both relations also need to have  
> cascade="all, delete-orphan" set up so that SQLAs management of  
> already loaded objects understands that these collections are deleted  
> along with the parent.

Bingo, I was missing a passive_deletes=True.  Thank you again!

> Additionally, if apple CASCADEs to oranges, there is no need to issue  
> an explicit session.delete() on each orange object - that can also  
> produce conflicting activity.

Right, but we're not deleting apples. :-)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to