[Django] #31835: JSONField's __cointains lookup doesn't work in nested values on Oracle.

13 views
Skip to first unread message

Django

unread,
Jul 28, 2020, 3:12:23 AM7/28/20
to django-...@googlegroups.com
#31835: JSONField's __cointains lookup doesn't work in nested values on Oracle.
-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: felixxm
Type: Bug | Status: assigned
Component: Database | Version: 3.1
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Oracle doesn't provide a native way for testing containment of JSONField.
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"''.

It looks that building multi-level/recursive filters with `JSON_EXISTS()`
is the only feasible way, but it's really complicated and can be clunky.

I think we should drop this lookup on Oracle and raise
`NotSupportedError`.

Some examples:
{{{
diff --git a/tests/model_fields/test_jsonfield.py
b/tests/model_fields/test_jsonfield.py
index 3ce7fc51a9..b659675ec8 100644
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -445,8 +445,12 @@ class TestQuerying(TestCase):
tests = [
({}, self.objs[2:5] + self.objs[6:8]),
({'baz': {'a': 'b', 'c': 'd'}}, [self.objs[7]]),
+ ({'baz': {'a': 'b'}}, [self.objs[7]]),
+ ({'baz': {'c': 'd'}}, [self.objs[7]]),
({'k': True, 'l': False}, [self.objs[6]]),
({'d': ['e', {'f': 'g'}]}, [self.objs[4]]),
+ ({'d': ['e']}, [self.objs[4]]),
+ ({'d': [{'f': 'g'}]}, [self.objs[4]]),
([1, [2]], [self.objs[5]]),
({'n': [None]}, [self.objs[4]]),
({'j': None}, [self.objs[4]]),
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31835>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 28, 2020, 3:18:28 AM7/28/20
to django-...@googlegroups.com
#31835: JSONField's __contains lookup doesn't work in nested values on Oracle.

-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: felixxm
Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/31835#comment:1>

Django

unread,
Jul 28, 2020, 4:34:15 AM7/28/20
to django-...@googlegroups.com
#31835: JSONField's __contains lookup doesn't work in nested values on Oracle.

-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: felixxm
Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/13248 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31835#comment:2>

Django

unread,
Jul 28, 2020, 5:54:30 AM7/28/20
to django-...@googlegroups.com
#31835: JSONField's __contains lookup doesn't work in nested values on Oracle.

-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: felixxm
Type: Bug | Status: closed

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"02447fb133b53ec7d0ff068cc08f06fdf8817ef7" 02447fb1]:
{{{
#!CommitTicketReference repository=""
revision="02447fb133b53ec7d0ff068cc08f06fdf8817ef7"
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".
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31835#comment:3>

Django

unread,
Jul 28, 2020, 5:56:01 AM7/28/20
to django-...@googlegroups.com
#31835: JSONField's __contains lookup doesn't work in nested values on Oracle.

-------------------------------------+-------------------------------------
Reporter: felixxm | Owner: felixxm
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"028a5f86f22d4be0746cbd38d09d6961024b2ef7" 028a5f8]:
{{{
#!CommitTicketReference repository=""
revision="028a5f86f22d4be0746cbd38d09d6961024b2ef7"
[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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31835#comment:4>

Reply all
Reply to author
Forward
0 new messages