Hermann Himmelbauer wrote:
>
> Hi,
> I use in my database tables, that reference other tables, e.g. table A ->
> table B. In my deletion routine, I want to prohibit people to delete rows
> from A, which have references to B.
>
> How would I do that?
>
> My first approach was to rely on the databases referential integrity and
> catch
> related dabases errors, however, SQLAlchemy works around these references,
> as
> due to the "cascade = all" rule in the mapper, the rows of table "B" are
> simply deleted before.
>
> On the other hand, I can't simply omit "cascade=all", as I need this for
> object creation.

cascade="all" includes delete".  the default is "save-update,merge", and
that is all you need for object creation.   make sure your foreign key
columns are created as NOT NULL and an error will generate when SQLA
attempts to set them to null.



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