an certain anagrafica has another parent which conflicts delete-orphan.

The anagrafica's relationship may has done by just setting 
anagrafica.azienda_pk (not by azienda.anagrafica_set.append )


(Sorry about that separated mail...my mistake.)


Regards,

Tate
-----Original Message-----
From: "Tate Kim" <insight...@gmail.com>
Date: Fri, 24 Feb 2012 17:56:44 
To: <sqlalchemy@googlegroups.com>
Reply-To: insight...@gmail.com
Subject: Re: [sqlalchemy] on delete cascade

Hi, jo.

At first, try with cascade option 'all, delete'
(note that dropped 'delete-orphan').

Second, I've ever been your situation before, maybe 
-----Original Message-----
From: jo <jose.soa...@sferacarta.com>
Sender: sqlalchemy@googlegroups.com
Date: Fri, 24 Feb 2012 11:41:48 
To: sa<sqlalchemy@googlegroups.com>
Reply-To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] on delete cascade

Hi all,

I'm trying to delete cascade a linked row without success.
Could anyone give me some help?


This is my mapper:

mapper(Azienda,
       tbl['azienda'],
       properties = {
           'anagrafica': relation(Anagrafica, cascade='all, delete, 
delete-orphan'),
       })

the table Azienda has a foreign key (not null) linked to table Anagrafica.


When I try to delete a row from Azienda I would like remove also the 
linked row in table Anagrafica... and I supposed it was done by
the instruction on properties:  'anagrafica': relation(Anagrafica, 
cascade='all, delete, delete-orphan')... but it doesn't work...

record = Azienda.get( 867 )
session.delete(record)

IntegrityError: ('(IntegrityError) update or delete on table 
"anagrafica" violates
foreign key constraint "azienda_id_anagrafica_fkey" on table "azienda"
DETAIL: Key (id)=(313836) is still referenced from table "azienda".
, <bound method Controller.save of 
<sicer.BASE.controller.anagraficaAlta.azienda.Controller object at 
0x8fde590>>)
'DELETE FROM anagrafica WHERE anagrafica.id = %(id)s' {'id': 313836}

Thanks for any help

j

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

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