James Bennett wrote:
> On 9/12/06, Gary Doades <[EMAIL PROTECTED]> wrote:
>> As an example, I have a table (product) that is referenced by 11 other tables
>> (booking, history, rates, invoice, payroll, timesheets etc.). Those tables
>> contain upwards of 10 million rows in the existing application. I certainly
>> don't want those records to be deleted just because (by whatever means)
>> someone tried to delete a product!!
> 
> There are some checks in place for this; the admin app, for example,
> will display a confirmation page before allowing a delete, and that
> page lists every related object that will be deleted.
> 
> Much of the problem with this is that certain databases
> *cough*sqlite*cough*mysql*cough* have issues with specifying delete
> behavior at the SQL level. I've written this up at some length on the
> Django developers list[1], but here's the executive summary:
 >
 > <snip>
> 

couldn't we solve this (at least for now) on the django-level?


from the source code it seems that the "cascading" is done in the 
django-code, and not on the db-level.

========================================
     def delete(self):
         assert self._get_pk_val() is not None, "%s object can't be 
deleted because its %s attribute is set to None." % 
(self._meta.object_name, self._meta.pk.attname)

         # Find all the objects than need to be deleted
         seen_objs = SortedDict()
         self._collect_sub_objects(seen_objs)

         # Actually delete the objects
         delete_objects(seen_objs)
========================================


couldn't we simply add a boolean-parameter to delete(), something like 
"def delete(cascade=True)"?

and when cascading is set to false, we would only (try to) delete the
given object, and leave it to the caller to handle the potential error.

for me, this would completely solve my problem. also, in your own model 
classes, you can simply override delete, and call the parent's delete, 
and handle the error there. so this seems to me as a suitable way.

what do you think?

gabor

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to