#9519: Add QuerySet.bulk_delete() that issues only a single SQL query
-------------------------------------+-------------------------------------
               Reporter:  Tarken     |          Owner:  tobias
                   Type:  New        |         Status:  assigned
  feature                            |      Component:  Database layer
              Milestone:             |  (models, ORM)
                Version:  SVN        |       Severity:  Normal
             Resolution:             |       Keywords:  database, queryset,
           Triage Stage:  Accepted   |  delete
    Needs documentation:  0          |      Has patch:  0
Patch needs improvement:  0          |    Needs tests:  0
                  UI/UX:  0          |  Easy pickings:  0
-------------------------------------+-------------------------------------
Changes (by carljm):

 * version:  1.0 => SVN
 * stage:  Design decision needed => Accepted


Comment:

 .delete() has to be implemented the way it is in order to support cascade-
 deletion. If Django didn't do cascade-deletion in the ORM it would be much
 more difficult to write cross-database-compatible ORM code. So the
 implementation of .delete() is not going to change (it does do the cascade
 more efficiently now, since #7539 was fixed, than it did when this ticket
 was filed).

 The issue reported originally here (that deletion doesn't work with
 duplicate PKs) is a non-issue. Django's ORM assumes PKs are unique, and
 the database will enforce that unless your database is broken or you've
 manually modified the tables. That's not going to change, regardless of
 what hacky workarounds were suggested on #373.

 All that said, I'd be open to a new .bulk_delete() method (parallel to the
 .bulk_create() method that was recently added) that would do deletion as
 requested here. It would have a number of caveats, primarily that it
 wouldn't do FK cascades, so you'd have to have your database set up
 correctly to handle that natively (ON DELETE CASCADE or whatnot) or you
 might get integrity errors.

 natevw, if you think the documentation for the current .delete() method
 could better explain its limitations, that's a separate issue - please
 file a new ticket for it, ideally with a patch to the docs.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9519#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to