Ticket #33820: regression-tests-33820.diff

File regression-tests-33820.diff, 1.7 KB (added by Mariusz Felisiak, 2 years ago)
  • tests/model_fields/test_jsonfield.py

    commit ae426c0216803835b3406f37987033ea7b2d5cb0
    Author: Mariusz Felisiak <felisiak.mariusz@gmail.com>
    Date:   Tue Jul 12 10:29:15 2022 +0200
    
        Fixed #33820 --
        
        Thanks Johnny Metz for the report.
        
        Regression in 71ec102b01fcc85acae3819426a4e02ef423b0fa.
    
    diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
    index 25dfef7a24..5104f5273d 100644
    a b class TestQuerying(TestCase):  
    293293                "o": '"quoted"',
    294294                "p": 4.2,
    295295                "r": {"s": True, "t": False},
     296                "s": "null",
    296297            },
    297298            [1, [2]],
    298             {"k": True, "l": False, "foo": "bax"},
     299            {"k": True, "l": False, "s": None, "foo": "bax"},
    299300            {
    300301                "foo": "bar",
    301302                "baz": {"a": "b", "c": "d"},
    class TestQuerying(TestCase):  
    325326            [self.objs[3]],
    326327        )
    327328
     329    def test_exact_null(self):
     330        self.assertSequenceEqual(
     331            NullableJSONModel.objects.filter(value__s=Value("null")),
     332            [self.objs[6]],
     333        )
     334        self.assertSequenceEqual(
     335            NullableJSONModel.objects.filter(value__s="null"),
     336            [self.objs[4]],
     337        )
     338
    328339    def test_icontains(self):
    329340        self.assertCountEqual(
    330341            NullableJSONModel.objects.filter(value__icontains="BaX"),
    class TestQuerying(TestCase):  
    894905            ("value__n", [None, True, False]),
    895906            ("value__p", 4.2),
    896907            ("value__r", {"s": True, "t": False}),
     908            ("value__s", "null"),
    897909        ]
    898910        for lookup, expected in tests:
    899911            with self.subTest(lookup=lookup):
Back to Top