mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #22998 -- Updated the fast_delete logic for GFKs
This commit is contained in:
parent
28efafa24c
commit
6e2b82fdf6
3 changed files with 41 additions and 4 deletions
|
@ -2,11 +2,14 @@ from django.db.models import Q, Sum
|
|||
from django.db.utils import IntegrityError
|
||||
from django.test import TestCase, skipIfDBFeature
|
||||
from django.forms.models import modelform_factory
|
||||
from django.db.models.deletion import ProtectedError
|
||||
|
||||
from .models import (
|
||||
Address, Place, Restaurant, Link, CharLink, TextLink,
|
||||
Person, Contact, Note, Organization, OddRelation1, OddRelation2, Company,
|
||||
Developer, Team, Guild, Tag, Board, HasLinkThing, A, B, C, D)
|
||||
Developer, Team, Guild, Tag, Board, HasLinkThing, A, B, C, D,
|
||||
Related, Content, Node,
|
||||
)
|
||||
|
||||
|
||||
class GenericRelationTests(TestCase):
|
||||
|
@ -247,3 +250,13 @@ class GenericRelationTests(TestCase):
|
|||
form.save()
|
||||
links = HasLinkThing._meta.get_field_by_name('links')[0]
|
||||
self.assertEqual(links.save_form_data_calls, 1)
|
||||
|
||||
def test_ticket_22998(self):
|
||||
related = Related.objects.create()
|
||||
content = Content.objects.create(related_obj=related)
|
||||
node = Node.objects.create(content=content)
|
||||
|
||||
# deleting the Related cascades to the Content cascades to the Node,
|
||||
# where the pre_delete signal should fire and prevent deletion.
|
||||
with self.assertRaises(ProtectedError):
|
||||
related.delete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue