Fixed #15786 -- Added a regression test for o2o excludes using F().
The issue was reported against 1.3.x but has been fixed since.
This commit is contained in:
parent
b0e06c3662
commit
c4fdd859ec
|
@ -390,6 +390,10 @@ class OneToOneCategory(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "one2one " + self.new_name
|
return "one2one " + self.new_name
|
||||||
|
|
||||||
|
class CategoryRelationship(models.Model):
|
||||||
|
first = models.ForeignKey(SimpleCategory, related_name='first_rel')
|
||||||
|
second = models.ForeignKey(SimpleCategory, related_name='second_rel')
|
||||||
|
|
||||||
class NullableName(models.Model):
|
class NullableName(models.Model):
|
||||||
name = models.CharField(max_length=20, null=True)
|
name = models.CharField(max_length=20, null=True)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ from collections import OrderedDict
|
||||||
import datetime
|
import datetime
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
import pickle
|
import pickle
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -26,7 +25,8 @@ from .models import (
|
||||||
OneToOneCategory, NullableName, ProxyCategory, SingleObject, RelatedObject,
|
OneToOneCategory, NullableName, ProxyCategory, SingleObject, RelatedObject,
|
||||||
ModelA, ModelB, ModelC, ModelD, Responsibility, Job, JobResponsibilities,
|
ModelA, ModelB, ModelC, ModelD, Responsibility, Job, JobResponsibilities,
|
||||||
BaseA, FK1, Identifier, Program, Channel, Page, Paragraph, Chapter, Book,
|
BaseA, FK1, Identifier, Program, Channel, Page, Paragraph, Chapter, Book,
|
||||||
MyObject, Order, OrderItem, SharedConnection, Task, Staff, StaffUser)
|
MyObject, Order, OrderItem, SharedConnection, Task, Staff, StaffUser,
|
||||||
|
CategoryRelationship)
|
||||||
|
|
||||||
class BaseQuerysetTest(TestCase):
|
class BaseQuerysetTest(TestCase):
|
||||||
def assertValueQuerysetEqual(self, qs, values):
|
def assertValueQuerysetEqual(self, qs, values):
|
||||||
|
@ -2452,6 +2452,21 @@ class ExcludeTest17600(TestCase):
|
||||||
Order.objects.exclude(~Q(items__status=1)).distinct(),
|
Order.objects.exclude(~Q(items__status=1)).distinct(),
|
||||||
['<Order: 1>'])
|
['<Order: 1>'])
|
||||||
|
|
||||||
|
class Exclude15786(TestCase):
|
||||||
|
"""Regression test for #15786"""
|
||||||
|
def test_ticket15786(self):
|
||||||
|
c1 = SimpleCategory.objects.create(name='c1')
|
||||||
|
c2 = SimpleCategory.objects.create(name='c2')
|
||||||
|
o2o1 = OneToOneCategory.objects.create(category=c1)
|
||||||
|
o2o2 = OneToOneCategory.objects.create(category=c2)
|
||||||
|
rel = CategoryRelationship.objects.create(first=c1, second=c2)
|
||||||
|
self.assertEqual(
|
||||||
|
CategoryRelationship.objects.exclude(
|
||||||
|
first__onetoonecategory=F('second__onetoonecategory')
|
||||||
|
).get(), rel
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NullInExcludeTest(TestCase):
|
class NullInExcludeTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
NullableName.objects.create(name='i1')
|
NullableName.objects.create(name='i1')
|
||||||
|
|
Loading…
Reference in New Issue