mirror of https://github.com/django/django.git
[3.1.x] Added test for filtering JSONField key transforms with quoted strings.
Backport of bec415b290
from master
This commit is contained in:
parent
166c0d2474
commit
a582ef8b89
|
@ -261,6 +261,7 @@ class TestQuerying(TestCase):
|
||||||
'j': None,
|
'j': None,
|
||||||
'k': {'l': 'm'},
|
'k': {'l': 'm'},
|
||||||
'n': [None],
|
'n': [None],
|
||||||
|
'o': '"quoted"',
|
||||||
},
|
},
|
||||||
[1, [2]],
|
[1, [2]],
|
||||||
{'k': True, 'l': False},
|
{'k': True, 'l': False},
|
||||||
|
@ -705,6 +706,12 @@ class TestQuerying(TestCase):
|
||||||
def test_key_iregex(self):
|
def test_key_iregex(self):
|
||||||
self.assertIs(NullableJSONModel.objects.filter(value__foo__iregex=r'^bAr$').exists(), True)
|
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')
|
@skipUnlessDBFeature('has_json_operators')
|
||||||
def test_key_sql_injection(self):
|
def test_key_sql_injection(self):
|
||||||
with CaptureQueriesContext(connection) as queries:
|
with CaptureQueriesContext(connection) as queries:
|
||||||
|
|
Loading…
Reference in New Issue