From bec415b290b68c07adcd9c67631b6573666d76be Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 20 Nov 2020 07:25:32 +0100 Subject: [PATCH] Added test for filtering JSONField key transforms with quoted strings. --- tests/model_fields/test_jsonfield.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index e39e3fe757..8bec000100 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -276,6 +276,7 @@ class TestQuerying(TestCase): 'j': None, 'k': {'l': 'm'}, 'n': [None], + 'o': '"quoted"', }, [1, [2]], {'k': True, 'l': False, 'foo': 'bax'}, @@ -774,6 +775,12 @@ class TestQuerying(TestCase): def test_key_iregex(self): self.assertIs(NullableJSONModel.objects.filter(value__foo__iregex=r'^bAr$').exists(), True) + def test_key_quoted_string(self): + self.assertEqual( + NullableJSONModel.objects.filter(value__o='"quoted"').get(), + self.objs[4], + ) + @skipUnlessDBFeature('has_json_operators') def test_key_sql_injection(self): with CaptureQueriesContext(connection) as queries: