Fixed #31624 -- Avoided subquery usage on QuerySet.all().delete().

Thanks Adam Johnson for the report.

Regression in 7acef095d7.
This commit is contained in:
Simon Charette 2020-05-24 09:18:12 -04:00 committed by Mariusz Felisiak
parent 437196da9a
commit 972000420e
2 changed files with 8 additions and 0 deletions

View file

@ -605,6 +605,12 @@ class DeletionTests(TestCase):
class FastDeleteTests(TestCase):
def test_fast_delete_all(self):
with self.assertNumQueries(1) as ctx:
User.objects.all().delete()
sql = ctx.captured_queries[0]['sql']
# No subqueries is used when performing a full delete.
self.assertNotIn('SELECT', sql)
def test_fast_delete_fk(self):
u = User.objects.create(