Now for one of the reasons that I've been trying to get the Django unit tests running: I'm interested in submitting a patch that adds some ON DELETE and ON UPDATE support in Django. But first, I want to see what interest there is in such a patch. There have been a number of tickets about this over the years, but none that I've seen uses this approach. For instance:
http://code.djangoproject.com/ticket/28 (closed: duplicate) http://code.djangoproject.com/ticket/1007 (closed: duplicate) http://code.djangoproject.com/ticket/2288 (closed: won't fix) http://code.djangoproject.com/ticket/6108 (new) Below is an outline of what the patch currently does and what I would need to add if there is interest in using it. * The patch adds on_delete and on_update keyword parameters to ForeignKey.__init__. * Usage looks like this: from django.db import models class ModelA(models.Model): id = models.PositiveIntegerField(primary_key=True) class ModelB(models.Model): partner = models.ForeignKey( ModelA, on_delete=models.CASCADE, on_update=models.CASCADE ) * If settings.DATABASE_HANDLES_ON_DELETE=True, the SQL that is generated by manage.py contains ON DELETE clauses where on_delete=<option> is specified. * If settings.DATABASE_HANDLES_ON_UPDATE=True, the SQL that is generated by manage.py contains ON UPDATE clauses where on_update=<option> is specified. * The possible values that can be passed for the on_delete and on_update parameters are None, RESTRICT, CASCADE, and SET_NULL. * If settings.DATABASE_HANDLES_ON_DELETE=False, I hope to modify Django's code that currently automatically deletes related objects to respect the values specified by the on_delete parameter. This is one of the things I will probably postpone until I see if there is sufficient interest. * Another thing I need to do is to add Django unit test for the new behavior. This is why I've been trying to get the unit tests running. Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---