diff options
| author | Tim Graham <timograham@gmail.com> | 2020-05-18 02:12:20 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-05-18 08:12:57 +0200 |
| commit | 5480fab290655682db7fc12c087675df43115a01 (patch) | |
| tree | e2d6d04858f4f3555b36e76c5aed060442fd3406 /tests | |
| parent | 16716551bda6b088fcd41d7d12a782b758e8dcb7 (diff) | |
[3.1.x] Refs #12990 -- Added DatabaseFeatures.has_json_operators.
CockroachDB also has them.
Backport of f59a2b730685fc62c5cb44101f54faf8921d9bc7 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/model_fields/test_jsonfield.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index 464cf163d4..1e92b34791 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -17,7 +17,9 @@ from django.db.models.fields.json import ( KeyTransformTextLookupMixin, ) from django.db.models.functions import Cast -from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature +from django.test import ( + SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature, +) from django.test.utils import CaptureQueriesContext from .models import CustomJSONDecoder, JSONModel, NullableJSONModel @@ -607,7 +609,7 @@ class TestQuerying(TestCase): def test_key_iregex(self): self.assertIs(NullableJSONModel.objects.filter(value__foo__iregex=r'^bAr$').exists(), True) - @skipUnless(connection.vendor == 'postgresql', 'kwargs are crafted for PostgreSQL.') + @skipUnlessDBFeature('has_json_operators') def test_key_sql_injection(self): with CaptureQueriesContext(connection) as queries: self.assertIs( @@ -621,7 +623,7 @@ class TestQuerying(TestCase): queries[0]['sql'], ) - @skipIf(connection.vendor == 'postgresql', 'PostgreSQL uses operators not functions.') + @skipIfDBFeature('has_json_operators') def test_key_sql_injection_escape(self): query = str(JSONModel.objects.filter(**{ """value__test") = '"a"' OR 1 = 1 OR ("d""": 'x', |
