summaryrefslogtreecommitdiff
path: root/tests/delete_regress/tests.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-07-04 17:34:20 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-07-07 07:08:28 +0200
commit28e2077148f7602d29165e90965974698819cbba (patch)
tree538b9f14ee54dfd978f28e051422430b868e3a13 /tests/delete_regress/tests.py
parent95cdf9dc6627135f3893095892816eb3f2785e2e (diff)
Refs #32433 -- Reallowed calling QuerySet.delete() after distinct().
While values(*field_excluding_pk).distinct() and distinct(*field_excluding_pk) can reduce the number of resulting rows in a way that makes subsequent delete() calls ambiguous standalone .distinct() calls cannot. Since delete() already disallows chain usages with values() the only case that needs to be handled, as originally reported, is when DISTINCT ON is used via distinct(*fields). Refs #32682 which had to resort to subqueries to prevent duplicates in the admin and caused significant performance regressions on MySQL (refs #34639). This partly reverts 6307c3f1a123f5975c73b231e8ac4f115fd72c0d.
Diffstat (limited to 'tests/delete_regress/tests.py')
-rw-r--r--tests/delete_regress/tests.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py
index 2540fd2802..71e3bcb405 100644
--- a/tests/delete_regress/tests.py
+++ b/tests/delete_regress/tests.py
@@ -396,10 +396,8 @@ class DeleteTests(TestCase):
class DeleteDistinct(SimpleTestCase):
- def test_disallowed_delete_distinct(self):
- msg = "Cannot call delete() after .distinct()."
- with self.assertRaisesMessage(TypeError, msg):
- Book.objects.distinct().delete()
+ def test_disallowed_delete_distinct_on(self):
+ msg = "Cannot call delete() after .distinct(*fields)."
with self.assertRaisesMessage(TypeError, msg):
Book.objects.distinct("id").delete()