diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-05-20 14:24:48 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-05-20 15:38:47 +0300 |
| commit | f53059b41148da77e8c4cdfcdbec3a7514cd97c9 (patch) | |
| tree | ff8d88fc23a439d5f67e162a20443c5625aac4e9 /tests | |
| parent | a93672622829e0d4a2ff3240456d4d73b9d46476 (diff) | |
Fixed qs.values() regression when used in subquery
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index cdc26248c9..ad5dde34b5 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2831,3 +2831,20 @@ class EmptyStringPromotionTests(TestCase): self.assertIn('LEFT OUTER JOIN', str(qs.query)) else: self.assertNotIn('LEFT OUTER JOIN', str(qs.query)) + +class ValuesSubqueryTests(TestCase): + def test_values_in_subquery(self): + # Check that if a values() queryset is used, then the given values + # will be used instead of forcing use of the relation's field. + o1 = Order.objects.create(id=-2) + o2 = Order.objects.create(id=-1) + oi1 = OrderItem.objects.create(order=o1, status=0) + oi1.status = oi1.pk + oi1.save() + OrderItem.objects.create(order=o2, status=0) + + # The query below should match o1 as it has related order_item + # with id == status. + self.assertQuerysetEqual( + Order.objects.filter(items__in=OrderItem.objects.values_list('status')), + [o1.pk], lambda x: x.pk) |
