From 7fa1a93c6c8109010a6ff3f604fda83b604e0e97 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 5 Feb 2020 14:31:30 +0100 Subject: [PATCH] Refs #28214 -- Added test for escaping JSONField key lookups. Thanks mrsanders for the report. Fixed in 7deeabc7c7526786df6894429ce89a9c4b614086. --- tests/postgres_tests/test_json.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/postgres_tests/test_json.py b/tests/postgres_tests/test_json.py index 0ffa05f981..2ff765e918 100644 --- a/tests/postgres_tests/test_json.py +++ b/tests/postgres_tests/test_json.py @@ -411,6 +411,10 @@ class TestQuerying(PostgreSQLTestCase): **{lookup: value}, ).exists()) + def test_key_escape(self): + obj = JSONModel.objects.create(field={'%total': 10}) + self.assertEqual(JSONModel.objects.filter(**{'field__%total': 10}).get(), obj) + @isolate_apps('postgres_tests') class TestChecks(PostgreSQLSimpleTestCase):