1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

[1.11.x] Fixed #28175 -- Fixed __in lookups on a foreign key when using the foreign key's parent model as the lookup value.

Thanks Simon Charette for review.

Backport of d66378a8b2 from master
This commit is contained in:
Tim Graham
2017-05-05 18:35:08 -04:00
parent 73d4560a92
commit f9a4593376
3 changed files with 11 additions and 1 deletions

View File

@@ -474,6 +474,12 @@ class ModelInheritanceTest(TestCase):
jane = Supplier.objects.order_by("name").select_related("restaurant")[0]
self.assertEqual(jane.restaurant.name, "Craft")
def test_filter_with_parent_fk(self):
r = Restaurant.objects.create()
s = Supplier.objects.create(restaurant=r)
# The mismatch between Restaurant and Place is intentional (#28175).
self.assertSequenceEqual(Supplier.objects.filter(restaurant__in=Place.objects.all()), [s])
def test_ptr_accessor_assigns_db(self):
r = Restaurant.objects.create()
self.assertEqual(r.place_ptr._state.db, 'default')