diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/one_to_one/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py index 6604299076..041fe6857c 100644 --- a/tests/one_to_one/tests.py +++ b/tests/one_to_one/tests.py @@ -479,3 +479,21 @@ class OneToOneTests(TestCase): Waiter.objects.update(restaurant=r2) w.refresh_from_db() self.assertEqual(w.restaurant, r2) + + def test_rel_pk_subquery(self): + r = Restaurant.objects.first() + q1 = Restaurant.objects.filter(place_id=r.pk) + # Test that subquery using primary key and a query against the + # same model works correctly. + q2 = Restaurant.objects.filter(place_id__in=q1) + self.assertQuerysetEqual(q2, [r], lambda x: x) + # Test that subquery using 'pk__in' instead of 'place_id__in' work, too. + q2 = Restaurant.objects.filter( + pk__in=Restaurant.objects.filter(place__id=r.place.pk) + ) + self.assertQuerysetEqual(q2, [r], lambda x: x) + + def test_rel_pk_exact(self): + r = Restaurant.objects.first() + r2 = Restaurant.objects.filter(pk__exact=r).first() + self.assertEqual(r, r2) |
