summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <anssi.kaariainen@thl.fi>2016-02-11 08:39:37 +0200
committerTim Graham <timograham@gmail.com>2016-02-11 11:09:08 -0500
commit46ecfb9b3a11a360724e3375ba78c33c46d6a992 (patch)
tree29826ddb4ce88d420826d63025fab3c808733d24 /tests
parent04e13c89138d48c20e774a2b6bf06796f73ac0fe (diff)
Fixed #26196 -- Made sure __in lookups use to_field as default.
Thanks Simon Charette for the test.
Diffstat (limited to 'tests')
-rw-r--r--tests/queries/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 91ff7bfc8d..e4cb420fda 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2416,6 +2416,18 @@ class ToFieldTests(TestCase):
{lunch, dinner},
)
+ def test_in_subquery(self):
+ apple = Food.objects.create(name="apple")
+ lunch = Eaten.objects.create(food=apple, meal="lunch")
+ self.assertEqual(
+ set(Eaten.objects.filter(food__in=Food.objects.filter(name='apple'))),
+ {lunch}
+ )
+ self.assertEqual(
+ set(Eaten.objects.filter(food__in=Food.objects.filter(name='apple').values('eaten__meal'))),
+ set()
+ )
+
def test_reverse_in(self):
apple = Food.objects.create(name="apple")
pear = Food.objects.create(name="pear")