Skip to content

Commit

Permalink
Refs #33374 -- Added tests for multi-table fast-deletion with filters…
Browse files Browse the repository at this point in the history
… that match everything.
  • Loading branch information
charettes authored and felixxm committed Nov 7, 2022
1 parent 7990d25 commit 4b702c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/delete/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from math import ceil

from django.db import connection, models
from django.db.models import ProtectedError, RestrictedError
from django.db.models import ProtectedError, Q, RestrictedError
from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
Expand Down Expand Up @@ -776,3 +776,10 @@ def test_fast_delete_aggregation(self):
(1, {"delete.Base": 1}),
)
self.assertIs(Base.objects.exists(), False)

def test_fast_delete_full_match(self):
avatar = Avatar.objects.create(desc="bar")
User.objects.create(avatar=avatar)
with self.assertNumQueries(1):
User.objects.filter(~Q(pk__in=[]) | Q(avatar__desc="foo")).delete()
self.assertFalse(User.objects.exists())

0 comments on commit 4b702c8

Please sign in to comment.