summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-28 11:54:01 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-28 11:54:35 +0200
commit028a5f86f22d4be0746cbd38d09d6961024b2ef7 (patch)
treefb837ef0b56a8c8c92c9a2d8e64ce15d56b4b384 /tests/model_fields
parent31164445599d8c1e69147485e418c6acc67e1278 (diff)
[3.1.x] Fixed #31835 -- Dropped support for JSONField __contains lookup on Oracle.
The current implementation works only for basic examples without supporting nested structures and doesn't follow "the general principle that the contained object must match the containing object as to structure and data contents, possibly after discarding some non-matching array elements or object key/value pairs from the containing object". Backport of 02447fb133b53ec7d0ff068cc08f06fdf8817ef7 from master
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/test_jsonfield.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
index 1e92b34791..7b81f3f22c 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -426,6 +426,10 @@ class TestQuerying(TestCase):
[self.objs[3], self.objs[4], self.objs[6]],
)
+ @skipIf(
+ connection.vendor == 'oracle',
+ "Oracle doesn't support contains lookup.",
+ )
def test_contains(self):
tests = [
({}, self.objs[2:5] + self.objs[6:8]),
@@ -441,6 +445,17 @@ class TestQuerying(TestCase):
qs = NullableJSONModel.objects.filter(value__contains=value)
self.assertSequenceEqual(qs, expected)
+ @skipUnless(
+ connection.vendor == 'oracle',
+ "Oracle doesn't support contains lookup.",
+ )
+ def test_contains_unsupported(self):
+ msg = 'contains lookup is not supported on Oracle.'
+ with self.assertRaisesMessage(NotSupportedError, msg):
+ NullableJSONModel.objects.filter(
+ value__contains={'baz': {'a': 'b', 'c': 'd'}},
+ ).get()
+
@skipUnlessDBFeature('supports_primitives_in_json_field')
def test_contains_primitives(self):
for value in self.primitives:
@@ -647,12 +662,12 @@ class TestQuerying(TestCase):
('value__baz__has_key', 'c'),
('value__baz__has_keys', ['a', 'c']),
('value__baz__has_any_keys', ['a', 'x']),
- ('value__contains', KeyTransform('bax', 'value')),
('value__has_key', KeyTextTransform('foo', 'value')),
)
- # contained_by lookup is not supported on Oracle.
+ # contained_by and contains lookups are not supported on Oracle.
if connection.vendor != 'oracle':
tests += (
+ ('value__contains', KeyTransform('bax', 'value')),
('value__baz__contained_by', {'a': 'b', 'c': 'd', 'e': 'f'}),
(
'value__contained_by',