summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2012-03-17 01:24:39 +0000
committerCarl Meyer <carl@oddbird.net>2012-03-17 01:24:39 +0000
commitddd53dafb5fa6ba3cd5075c8e7b3214556c73b50 (patch)
tree561e565c62bcc427d6a1b1985e5ff3247b0ac738 /tests
parentedcaf8b7ffb035c3b699b6fb72a0d467e5ec2474 (diff)
Fixed #17918 - Handle proxy models correctly when sorting deletions for databases without deferred constraints. Thanks Nate Bragg for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/delete_regress/models.py4
-rw-r--r--tests/regressiontests/delete_regress/tests.py23
2 files changed, 25 insertions, 2 deletions
diff --git a/tests/regressiontests/delete_regress/models.py b/tests/regressiontests/delete_regress/models.py
index 214452c97b..5db253f713 100644
--- a/tests/regressiontests/delete_regress/models.py
+++ b/tests/regressiontests/delete_regress/models.py
@@ -90,4 +90,6 @@ class FooFile(models.Model):
class FooPhoto(models.Model):
my_photo = models.ForeignKey(Photo)
-
+class FooFileProxy(FooFile):
+ class Meta:
+ proxy = True
diff --git a/tests/regressiontests/delete_regress/tests.py b/tests/regressiontests/delete_regress/tests.py
index 889fba81be..32feae2ded 100644
--- a/tests/regressiontests/delete_regress/tests.py
+++ b/tests/regressiontests/delete_regress/tests.py
@@ -8,7 +8,7 @@ from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
PlayedWithNote, Email, Researcher, Food, Eaten, Policy, Version, Location,
- Item, Image, File, Photo, FooFile, FooImage, FooPhoto)
+ Item, Image, File, Photo, FooFile, FooImage, FooPhoto, FooFileProxy)
# Can't run this test under SQLite, because you can't
@@ -237,3 +237,24 @@ class ProxyDeleteTest(TestCase):
# to it.
self.assertEqual(len(FooFile.objects.all()), 0)
self.assertEqual(len(FooImage.objects.all()), 0)
+
+
+ def test_delete_proxy_pair(self):
+ """
+ If a pair of proxy models are linked by an FK from one concrete parent
+ to the other, deleting one proxy model cascade-deletes the other, and
+ the deletion happens in the right order (not triggering an
+ IntegrityError on databases unable to defer integrity checks).
+
+ Refs #17918.
+
+ """
+ # Create an Image (proxy of File) and FooFileProxy (proxy of FooFile,
+ # which has an FK to File)
+ image = Image.objects.create()
+ as_file = File.objects.get(pk=image.pk)
+ FooFileProxy.objects.create(my_file=as_file)
+
+ Image.objects.all().delete()
+
+ self.assertEqual(len(FooFileProxy.objects.all()), 0)