mirror of
https://github.com/django/django.git
synced 2025-08-15 16:20:37 +00:00
[1.9.x] Fixed #26196 -- Made sure __in lookups use to_field as default.
Thanks Simon Charette for the test.
Backport of 46ecfb9b3a
from master
This commit is contained in:
parent
25496f0f7b
commit
1d9ee181fe
6 changed files with 25 additions and 4 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue