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:55 -0500
commit1d9ee181fe09a5c3784bbbf802cc522f11ff25ef (patch)
tree631f3b6efd4de904401188b62fc0dc6150150f36 /tests
parent25496f0f7b953b9bca709ab20bc536137f57402d (diff)
[1.9.x] Fixed #26196 -- Made sure __in lookups use to_field as default.
Thanks Simon Charette for the test. Backport of 46ecfb9b3a11a360724e3375ba78c33c46d6a992 from master
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 98d68d4092..7c306c9f15 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2463,6 +2463,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")