Skip to content

Commit

Permalink
Fixed #19939 -- generic relations + split_exclude regression
Browse files Browse the repository at this point in the history
Added a test, the issue was already fixed (likely by the patch
for #19385).
  • Loading branch information
akaariai committed May 11, 2013
1 parent 92351c7 commit c0d8932
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/generic_relations/models.py
Expand Up @@ -98,3 +98,7 @@ class Gecko(models.Model):
# To test fix for #11263
class Rock(Mineral):
tags = generic.GenericRelation(TaggedItem)

class ManualPK(models.Model):
id = models.IntegerField(primary_key=True)
tags = generic.GenericRelation(TaggedItem)
7 changes: 6 additions & 1 deletion tests/generic_relations/tests.py
Expand Up @@ -6,7 +6,7 @@
from django.test import TestCase

from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
Vegetable, Mineral, Gecko, Rock)
Vegetable, Mineral, Gecko, Rock, ManualPK)


class GenericRelationsTests(TestCase):
Expand Down Expand Up @@ -75,12 +75,17 @@ def test_generic_relations(self):
"<Animal: Lion>",
"<Animal: Platypus>"
])
# Create another fatty tagged instance with different PK to ensure
# there is a content type restriction in the generated queries below.
mpk = ManualPK.objects.create(id=lion.pk)
mpk.tags.create(tag="fatty")
self.assertQuerysetEqual(Animal.objects.filter(tags__tag='fatty'), [
"<Animal: Platypus>"
])
self.assertQuerysetEqual(Animal.objects.exclude(tags__tag='fatty'), [
"<Animal: Lion>"
])
mpk.delete()

# If you delete an object with an explicit Generic relation, the related
# objects are deleted when the source object is deleted.
Expand Down

0 comments on commit c0d8932

Please sign in to comment.