1
0
mirror of https://github.com/django/django.git synced 2025-10-29 08:36:09 +00:00

[1.10.x] Refs #26983 -- Added test for isnull lookup to CharField with primary_key=True.

Backport of 97513269d7 from master
This commit is contained in:
Chris Lamb
2016-08-17 21:09:50 +01:00
committed by Tim Graham
parent 04f0c2ab39
commit c24a47b3e6
3 changed files with 13 additions and 3 deletions

View File

@@ -2483,7 +2483,16 @@ class ToFieldTests(TestCase):
[node1]
)
def test_isnull_query(self):
class IsNullTests(TestCase):
def test_primary_key(self):
custom = CustomPk.objects.create(name='pk')
null = Related.objects.create()
notnull = Related.objects.create(custom=custom)
self.assertSequenceEqual(Related.objects.filter(custom__isnull=False), [notnull])
self.assertSequenceEqual(Related.objects.filter(custom__isnull=True), [null])
def test_to_field(self):
apple = Food.objects.create(name="apple")
Eaten.objects.create(food=apple, meal="lunch")
Eaten.objects.create(meal="lunch")