diff options
| author | Chris Lamb <chris@chris-lamb.co.uk> | 2016-08-17 21:09:50 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-17 21:08:15 -0400 |
| commit | 97513269d73520d10722bbd10404be6ac4d48d07 (patch) | |
| tree | 7b445abe715cfa9b670a69c65dc010150d910e88 | |
| parent | 3d0a3c5fff2f9ee5e0d7ee3340878e0986b0e3b2 (diff) | |
Refs #26983 -- Added test for isnull lookup to CharField with primary_key=True.
| -rw-r--r-- | docs/releases/1.10.1.txt | 3 | ||||
| -rw-r--r-- | tests/queries/models.py | 2 | ||||
| -rw-r--r-- | tests/queries/tests.py | 11 |
3 files changed, 13 insertions, 3 deletions
diff --git a/docs/releases/1.10.1.txt b/docs/releases/1.10.1.txt index eebe4e44d1..a6c019c4b3 100644 --- a/docs/releases/1.10.1.txt +++ b/docs/releases/1.10.1.txt @@ -28,7 +28,8 @@ Bugfixes (:ticket:`27005`). * Fixed the ``isnull`` lookup on a ``ForeignKey`` with its ``to_field`` - pointing to a ``CharField`` (:ticket:`26983`). + pointing to a ``CharField`` or pointing to a ``CharField`` defined with + ``primary_key=True`` (:ticket:`26983`). * Prevented the ``migrate`` command from raising ``InconsistentMigrationHistory`` in the presence of unapplied squashed diff --git a/tests/queries/models.py b/tests/queries/models.py index 523b58c7e4..c0ce3a5d60 100644 --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -261,7 +261,7 @@ class CustomPk(models.Model): class Related(models.Model): - custom = models.ForeignKey(CustomPk, models.CASCADE) + custom = models.ForeignKey(CustomPk, models.CASCADE, null=True) class CustomPkTag(models.Model): diff --git a/tests/queries/tests.py b/tests/queries/tests.py index a82f59e231..f5a2de8eba 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2482,7 +2482,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") |
