Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.1.X] Fixed #12721: Ensured objects with generic relations that use…

… non-integer object ID fields can be deleted on PostgreSQL. Thanks much carljm for patch and Russ for review.

r12353 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12355 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4043521f538c68f17605e37a2ceae1148d7da64a 1 parent ab75fd4
Karen Tracey kmtracey authored
19 tests/regressiontests/generic_relations_regress/models.py
View
@@ -40,3 +40,22 @@ class Person(models.Model):
def __unicode__(self):
return self.name
+
+class CharLink(models.Model):
+ content_type = models.ForeignKey(ContentType)
+ object_id = models.CharField(max_length=100)
+ content_object = generic.GenericForeignKey()
+
+class TextLink(models.Model):
+ content_type = models.ForeignKey(ContentType)
+ object_id = models.TextField()
+ content_object = generic.GenericForeignKey()
+
+class OddRelation1(models.Model):
+ name = models.CharField(max_length=100)
+ clinks = generic.GenericRelation(CharLink)
+
+class OddRelation2(models.Model):
+ name = models.CharField(max_length=100)
+ tlinks = generic.GenericRelation(TextLink)
+
12 tests/regressiontests/generic_relations_regress/tests.py
View
@@ -1,6 +1,6 @@
from django.test import TestCase
from django.contrib.contenttypes.models import ContentType
-from models import Link, Place, Restaurant, Person, Address
+from models import Link, Place, Restaurant, Person, Address, CharLink, TextLink, OddRelation1, OddRelation2
class GenericRelationTests(TestCase):
@@ -30,3 +30,13 @@ def test_reverse_relation_pk(self):
qs = Person.objects.filter(addresses__zipcode='80433')
self.assertEqual(1, qs.count())
self.assertEqual('Chef', qs[0].name)
+
+ def test_charlink_delete(self):
+ oddrel = OddRelation1.objects.create(name='clink')
+ cl = CharLink.objects.create(content_object=oddrel)
+ oddrel.delete()
+
+ def test_textlink_delete(self):
+ oddrel = OddRelation2.objects.create(name='tlink')
+ tl = TextLink.objects.create(content_object=oddrel)
+ oddrel.delete()
Please sign in to comment.
Something went wrong with that request. Please try again.