mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #18676 -- Allow fast-path deletion of objects
Objects can be fast-path deleted if there are no signals, and there are no further cascades. If fast-path is taken, the objects do not need to be loaded into memory before deletion. Thanks to Jeremy Dunck, Simon Charette and Alex Gaynor for reviewing the patch.
This commit is contained in:
@@ -17,7 +17,7 @@ from django.utils.formats import localize
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils import six
|
||||
|
||||
from .models import Article, Count, Event, Location
|
||||
from .models import Article, Count, Event, Location, EventGuide
|
||||
|
||||
|
||||
class NestedObjectsTests(TestCase):
|
||||
@@ -71,6 +71,17 @@ class NestedObjectsTests(TestCase):
|
||||
# Should not require additional queries to populate the nested graph.
|
||||
self.assertNumQueries(2, self._collect, 0)
|
||||
|
||||
def test_on_delete_do_nothing(self):
|
||||
"""
|
||||
Check that the nested collector doesn't query for DO_NOTHING objects.
|
||||
"""
|
||||
n = NestedObjects(using=DEFAULT_DB_ALIAS)
|
||||
objs = [Event.objects.create()]
|
||||
EventGuide.objects.create(event=objs[0])
|
||||
with self.assertNumQueries(2):
|
||||
# One for Location, one for Guest, and no query for EventGuide
|
||||
n.collect(objs)
|
||||
|
||||
class UtilTests(unittest.TestCase):
|
||||
def test_values_from_lookup_field(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user