1
0
mirror of https://github.com/django/django.git synced 2024-11-18 15:34:16 +00:00
Commit Graph

12 Commits

Author SHA1 Message Date
Anssi Kääriäinen
01e8ac47b3 PEP-8 cleanup
Refs #21169
2013-11-27 19:45:47 +02:00
Loic Bistuer
f450bc9f44 Added a bulk option to RelatedManager remove() and clear() methods
Refs #21169
2013-11-27 19:45:22 +02:00
Loic Bistuer
17c3997f68 Fixed #21169 -- Reworked RelatedManager methods use default filtering
The `remove()` and `clear()` methods of the related managers created by
`ForeignKey`, `GenericForeignKey`, and `ManyToManyField` suffered from a
number of issues. Some operations ran multiple data modifying queries without
wrapping them in a transaction, and some operations didn't respect default
filtering when it was present (i.e. when the default manager on the related
model implemented a custom `get_queryset()`).

Fixing the issues introduced some backward incompatible changes:

- The implementation of `remove()` for `ForeignKey` related managers changed
  from a series of `Model.save()` calls to a single `QuerySet.update()` call.
  The change means that `pre_save` and `post_save` signals aren't called anymore.

- The `remove()` and `clear()` methods for `GenericForeignKey` related
  managers now perform bulk delete so `Model.delete()` isn't called anymore.

- The `remove()` and `clear()` methods for `ManyToManyField` related
  managers perform nested queries when filtering is involved, which may
  or may not be an issue depending on the database and the data itself.

Refs. #3871, #21174.

Thanks Anssi Kääriäinen and Tim Graham for the reviews.
2013-11-27 19:44:18 +02:00
Alasdair Nicol
bab9123daa Fixed #21268 -- Fixed E303 pep8 warnings 2013-10-18 01:46:24 +01:00
Loic Bistuer
04a2a6b0f9 Fixed #3871 -- Custom managers when traversing reverse relations. 2013-09-25 21:15:59 +03:00
Alex Gaynor
9d11522599 Removed some more unused local vars 2013-09-08 12:20:01 -07:00
Tim Graham
5649c0af9d Fixed "indentation is not a multiple of four" pep8 issues. 2013-09-03 14:22:21 -04:00
Claude Paroz
5c1143910e Removed most of absolute_import imports
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
2013-07-29 20:28:13 +02:00
Julien Phalip
47c755327b Fixed a number of minor misspellings. 2013-07-27 18:46:03 -07:00
Loic Bistuer
31fadc1202 Fixed #20625 -- Chainable Manager/QuerySet methods.
Additionally this patch solves the orthogonal problem that specialized
`QuerySet` like `ValuesQuerySet` didn't inherit from the current `QuerySet`
type. This wasn't an issue until now because we didn't officially support
custom `QuerySet` but it became necessary with the introduction of this new
feature.

Thanks aaugustin, akaariai, carljm, charettes, mjtamlyn, shaib and timgraham
for the reviews.
2013-07-26 12:41:27 +03:00
Marc Tamlyn
09f8652765 Use assertIsInstance in tests.
Gives much nicer errors when it fails.
2013-05-21 10:42:15 +01:00
Florian Apolloner
89f40e3624 Merged regressiontests and modeltests into the test root. 2013-02-26 14:36:57 +01:00