Fixed #20564 -- Generic relations exclude() regression

The patch for #19385 caused a regression in certain generic relations
.exclude() filters if a subquery was needed. The fix contains a
refactoring to how Query.split_exclude() and Query.trim_start()
interact.

Thanks to Trac alias nferrari for the report.
This commit is contained in:
Anssi Kääriäinen 2013-06-06 00:29:44 +03:00
parent 8c5b805ca1
commit 31fd64ad8a
3 changed files with 138 additions and 51 deletions

View file

@ -131,3 +131,27 @@ class HasLinks(models.Model):
class HasLinkThing(HasLinks):
pass
class A(models.Model):
flag = models.NullBooleanField()
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
class B(models.Model):
a = generic.GenericRelation(A)
class Meta:
ordering = ('id',)
class C(models.Model):
b = models.ForeignKey(B)
class Meta:
ordering = ('id',)
class D(models.Model):
b = models.ForeignKey(B, null=True)
class Meta:
ordering = ('id',)