Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-10 Thread Russell Keith-Magee
On Thu, Jun 10, 2010 at 2:53 PM, Thomas Guettler wrote: > The documentation says django emulates "ON DELETE CASCADE": >   http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects > > But it is missing how to emulate ON DELETE SET NULL. > > In this thread Kevin

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-10 Thread Peter Bengtsson
Maybe the documentation is deliberately missing it because it's not supposed to have to be documented since it's supposed to just work. But as I'm suspecting, it doesn't. On 10 June 2010 02:53, Thomas Guettler wrote: > The documentation says django emulates "ON DELETE

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-10 Thread Harro
Also ON DELETE RESTRICT On Jun 10, 8:53 am, Thomas Guettler wrote: > The documentation says django emulates "ON DELETE CASCADE": >    http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects > > But it is missing how to emulate ON DELETE SET NULL. > > In this

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-10 Thread Thomas Guettler
The documentation says django emulates "ON DELETE CASCADE": http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects But it is missing how to emulate ON DELETE SET NULL. In this thread Kevin Howerton posted an abstract base class to emulate ON DELETE SET NULL. But this does

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-09 Thread Russell Keith-Magee
On Wed, Jun 9, 2010 at 3:53 AM, Peter Bengtsson wrote: > On 8 June 2010 13:09, Jeremy Dunck wrote: >> On Tue, Jun 8, 2010 at 7:30 AM, Peter Bengtsson wrote: >>> I've now had to learn this the hard way by having real live data >>> deleted

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-08 Thread Peter Bengtsson
On 8 June 2010 13:09, Jeremy Dunck wrote: > On Tue, Jun 8, 2010 at 7:30 AM, Peter Bengtsson wrote: >> I've now had to learn this the hard way by having real live data >> deleted from my database on two production projects and it pisses me >> off big time

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-08 Thread Kevin Howerton
This abstract base class likely is a bit less performant than having in-db support for cascades in pgsql... though it should give you the behavior you are seeking. It should set to default, or null if allowed. Enjoy. -k class ClearOnDelete(models.Model): def delete(self):

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-08 Thread Jeremy Dunck
On Tue, Jun 8, 2010 at 7:30 AM, Peter Bengtsson wrote: > I've now had to learn this the hard way by having real live data > deleted from my database on two production projects and it pisses me > off big time every time. > > I can accept that NOT nullable foreign relations

Re: Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-08 Thread Thomas Guettler
Hi, I think this is the related ticket: http://code.djangoproject.com/ticket/7539 "Add ON DELETE and ON UPDATE support to Django" Me and a lot of other people are on the cc list of this ticket. Peter Bengtsson wrote: > I've now had to learn this the hard way by having real live data > deleted

Beating on an old issue; counter intuitive cascade deletes on foreign keys

2010-06-08 Thread Peter Bengtsson
I've now had to learn this the hard way by having real live data deleted from my database on two production projects and it pisses me off big time every time. I can accept that NOT nullable foreign relations cascade the delete but not if they have null=True on them. Example: class