Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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 authored January 29, 2010
19  tests/regressiontests/generic_relations_regress/models.py
@@ -40,3 +40,22 @@ class Person(models.Model):
40 40
 
41 41
     def __unicode__(self):
42 42
         return self.name
  43
+
  44
+class CharLink(models.Model):
  45
+    content_type = models.ForeignKey(ContentType)
  46
+    object_id = models.CharField(max_length=100)
  47
+    content_object = generic.GenericForeignKey()
  48
+
  49
+class TextLink(models.Model):
  50
+    content_type = models.ForeignKey(ContentType)
  51
+    object_id = models.TextField()
  52
+    content_object = generic.GenericForeignKey()
  53
+
  54
+class OddRelation1(models.Model):
  55
+    name = models.CharField(max_length=100)
  56
+    clinks = generic.GenericRelation(CharLink)
  57
+
  58
+class OddRelation2(models.Model):
  59
+    name = models.CharField(max_length=100)
  60
+    tlinks = generic.GenericRelation(TextLink)
  61
+
12  tests/regressiontests/generic_relations_regress/tests.py
... ...
@@ -1,6 +1,6 @@
1 1
 from django.test import TestCase
2 2
 from django.contrib.contenttypes.models import ContentType
3  
-from models import Link, Place, Restaurant, Person, Address
  3
+from models import Link, Place, Restaurant, Person, Address, CharLink, TextLink, OddRelation1, OddRelation2
4 4
 
5 5
 class GenericRelationTests(TestCase):
6 6
 
@@ -30,3 +30,13 @@ def test_reverse_relation_pk(self):
30 30
         qs = Person.objects.filter(addresses__zipcode='80433')
31 31
         self.assertEqual(1, qs.count())
32 32
         self.assertEqual('Chef', qs[0].name)
  33
+
  34
+    def test_charlink_delete(self):
  35
+        oddrel = OddRelation1.objects.create(name='clink')
  36
+        cl = CharLink.objects.create(content_object=oddrel)
  37
+        oddrel.delete()
  38
+
  39
+    def test_textlink_delete(self):
  40
+        oddrel = OddRelation2.objects.create(name='tlink')
  41
+        tl = TextLink.objects.create(content_object=oddrel)
  42
+        oddrel.delete()

0 notes on commit 4043521

Please sign in to comment.
Something went wrong with that request. Please try again.