summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-08-02 17:27:45 +0200
committerClaude Paroz <claude@2xlibre.net>2016-08-04 16:07:11 +0200
commit6757c94662ef07e35eafcf3ac8bdae07a3d9326a (patch)
tree7c4cea5baade03bf45e3aa17aab0ad8aa6dc6e63 /tests
parentdcebeea2703322bc53c511bf3cff9e3c2e04d802 (diff)
[1.10.x] Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field
Thanks weidwonder for the report. Backport of 272eccf7ff0ced609e5a5e3bb6b4a40e773e0e66 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/queries/tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 48b57376f9..a3a810ce5e 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2483,6 +2483,19 @@ class ToFieldTests(TestCase):
[node1]
)
+ def test_isnull_query(self):
+ apple = Food.objects.create(name="apple")
+ Eaten.objects.create(food=apple, meal="lunch")
+ Eaten.objects.create(meal="lunch")
+ self.assertQuerysetEqual(
+ Eaten.objects.filter(food__isnull=False),
+ ['<Eaten: apple at lunch>']
+ )
+ self.assertQuerysetEqual(
+ Eaten.objects.filter(food__isnull=True),
+ ['<Eaten: None at lunch>']
+ )
+
class ConditionalTests(BaseQuerysetTest):
"""Tests whose execution depend on different environment conditions like