Ticket #30769: test-30769.diff

File test-30769.diff, 1.2 KB (added by Mariusz Felisiak, 5 years ago)

Regression test.

  • tests/postgres_tests/test_json.py

    diff --git a/tests/postgres_tests/test_json.py b/tests/postgres_tests/test_json.py
    index 333ed46bf1..459324e938 100644
    a b from decimal import Decimal  
    66from django.core import checks, exceptions, serializers
    77from django.core.serializers.json import DjangoJSONEncoder
    88from django.db import connection
    9 from django.db.models import Count, F, Q
     9from django.db.models import Count, F, OuterRef, Q, Subquery
    1010from django.db.models.expressions import RawSQL
    1111from django.db.models.functions import Cast
    1212from django.forms import CharField, Form, widgets
    class TestQuerying(PostgreSQLTestCase):  
    303303            [self.objs[7], self.objs[8]]
    304304        )
    305305
     306    def test_obj_subquery_lookup(self):
     307        qs = JSONModel.objects.annotate(
     308            value=Subquery(JSONModel.objects.filter(pk=OuterRef('pk')).values('field')),
     309        ).filter(value__a='b')
     310        self.assertSequenceEqual(
     311            qs,
     312            [self.objs[7], self.objs[8]]
     313        )
     314
    306315    def test_deep_lookup_objs(self):
    307316        self.assertSequenceEqual(
    308317            JSONModel.objects.filter(field__k__l='m'),
Back to Top