[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
This commit is contained in:
parent
ab75fd4786
commit
4043521f53
@ -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)
|
||||
|
||||
|
@ -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 @@ class GenericRelationTests(TestCase):
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user