#31836: JSONField's __contains and __contained_by lookups don't work with nested
values on SQLite.
-------------------------------------+-------------------------------------
               Reporter:  felixxm    |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              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          |
-------------------------------------+-------------------------------------
 SQLite 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"''.

 I'm not sure if it's feasible to emulate it in Python.

 Some (not really complicated) examples that don't work:
 {{{
 diff --git a/tests/model_fields/test_jsonfield.py
 b/tests/model_fields/test_jsonfield.py
 index 9a9e1a1286..1acc5af73e 100644
 --- a/tests/model_fields/test_jsonfield.py
 +++ b/tests/model_fields/test_jsonfield.py
 @@ -449,9 +449,14 @@ 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]]),
              ([1, [2]], [self.objs[5]]),
 +            ([1], [self.objs[5]]),
 +            ([[2]], [self.objs[5]]),
              ({'n': [None]}, [self.objs[4]]),
              ({'j': None}, [self.objs[4]]),
          ]
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.9f9556beab27c415ccee5b1e4c22954d%40djangoproject.com.

Reply via email to