On Feb 16, 2007, at 3:46 PM, jose wrote:
> No Jonathan, I don't want this column is set as NOT NULL, I have to
> allow null values for this column and I don't want enable the "ON  
> DELETE
> SET NULL" functionality.
> I would like SA have the same behavior as PostgreSQL has, I like the
> message:
>
> pg> delete from specie where codice='89';
> ERROR:  update or delete on "specie" violates foreign key constraint
> "attivita_cod_specie_fkey" on "attivita"
> DETAIL:  Key (codice)=(89) is still referenced from table "attivita".
>
> Is there another way to do that?


basically, if you have A->B, and you delete "A" without any kind of  
"delete" cascade to "B",  you are basically telling SA, "delete "A"  
from the database and keep "B"".   SA appropriately is smart enough  
to know that it should break the relationship from A to B before  
deleting A.

if that operation violates an integrity constraint in your  
application then youd have a NOT NULL constraint sitting on "B"'s  
foreign key to A.  That you say you dont want the "NOT NULL" on the  
column is a little strange...I dont exactly understand an  
"occasional" not-null constraint on a foreign key column.

you might find setting "delete-orphan" cascade on the relationship  
might raise an error for "B" sitting in the session by itself,  
though.  but then you cant save any "B"s by themselves.




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