> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Randy Syring
> Sent: 30 September 2008 07:17
> To: sqlalchemy
> Subject: [sqlalchemy] Re: How to turn off UPDATE on child 
> objects when deleting parent object
> 
> On Sep 30, 2:14 am, Randy Syring <[EMAIL PROTECTED]> wrote:
> > More details are 
> here:http://groups.google.com/group/sqlelixir/browse_thread/th
> read/aac5d22...
> >
> > But basically, I have a relationship between a parent 
> (Item) table and
> > child (Link) table.  When I try to delete an Item, an SQL 
> statement is
> > generated by SQLAlchemy that tries to set Link.item_id = NULL.  That
> > is invalid, because Link.item_id is a NOT NULL column and 
> also because
> > I have a FK on the column.  I have tried adjusting the 
> cascade options
> > to no avail.
> >
> 
> Sorry, one follow-up.  I can actually get this to work by setting
> cascade='all, delete-orphan'.  But since the FK will do a cascading
> delete, it is slower for SQLAlchemy to have to issue the statements.
> Can I just make SQLAlchemy not issue anything when deleting the
> parent?
> 

I think you need the 'passive_deletes' flag to tell SQLAlchemy that the 
database will delete child objects for you. It is described here:

http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_largecollections_passivedelete

Hope that helps,

Simon

--~--~---------~--~----~------------~-------~--~----~
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