[sqlalchemy] Re: on delete restrict (bis)

2007-09-09 Thread Jean-Philippe Dutreve
Another solution could be to inverse the order: - first delete the parent (so the rule RESTRICT is immediately fired) - second set null the FKs. On 8 sep, 19:52, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 8, 2007, at 12:54 PM, Jean-Philippe Dutreve wrote: My need is related to

[sqlalchemy] Re: on delete restrict (bis)

2007-09-09 Thread Michael Bayer
On Sep 9, 2007, at 5:09 AM, Jean-Philippe Dutreve wrote: Another solution could be to inverse the order: - first delete the parent (so the rule RESTRICT is immediately fired) - second set null the FKs. that would *really* add complexity to the core code just to support this feature.

[sqlalchemy] Re: on delete restrict (bis)

2007-09-09 Thread Michael Bayer
On Sep 9, 2007, at 5:09 AM, Jean-Philippe Dutreve wrote: Another solution could be to inverse the order: - first delete the parent (so the rule RESTRICT is immediately fired) - second set null the FKs. hm, except that RESTRICT is the same as the default of NO ACTION. The feature is added

[sqlalchemy] Re: on delete restrict (bis)

2007-09-09 Thread Michael Bayer
On Sep 9, 2007, at 12:21 PM, Jean-Philippe Dutreve wrote: I prefer put constraints in database rather than in application/ framework because several applications can access the same database and applications can gone quicker than DB. The ORM doesnt get in the way of your placing appropriate

[sqlalchemy] Re: on delete restrict (bis)

2007-09-08 Thread Michael Bayer
On Sep 8, 2007, at 12:54 PM, Jean-Philippe Dutreve wrote: My need is related to Postgresql ON DELETE RESTRICT/NO ACTION : I'd want a sql exception as soon as a parent having any existing child is deleted. I don't want cascade delete on children, just the parent but only if it has no child.

[sqlalchemy] Re: on delete restrict

2007-06-05 Thread Michael Bayer
On Jun 5, 2007, at 6:39 AM, lingo wrote: I'm using Sqlalchemy with PostgreSQL in a project. Some of the relations (foreign keys) in the database (postgresql) have ON_DELETE=RESTRICT which should prevent parent objects with existing child objects from being deleted (tested, works in pg

[sqlalchemy] Re: on delete restrict

2007-06-05 Thread Michael Bayer
On Jun 5, 2007, at 11:20 AM, lingo wrote: now it looks like: Parent_table = sa.Table('Parent', metadata, autoload=True) Child_table = sa.Table('Child', metadata, autoload=True) orm.mapper(Parent,Parent_table, properties={ 'Children' : relation(Child, cascade=save-update) } )