#32483: QuerySet.values()/values_list() with JSONField returns integers instead 
of
booleans on SQLite.
-------------------------------------+-------------------------------------
     Reporter:  Matthew Cornell      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  jsonfield querying   |             Triage Stage:  Accepted
  sqlite                             |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: sage (added)
 * severity:  Normal => Release blocker


Comment:

 Regression tests:
 {{{
 diff --git a/tests/model_fields/test_jsonfield.py
 b/tests/model_fields/test_jsonfield.py
 index 89b78de708..43ca00a4d1 100644
 --- a/tests/model_fields/test_jsonfield.py
 +++ b/tests/model_fields/test_jsonfield.py
 @@ -804,6 +804,16 @@ class TestQuerying(TestCase):
              with self.subTest(lookup=lookup):
                  self.assertEqual(qs.values_list(lookup, flat=True).get(),
 expected)

 +    def test_key_values_boolean(self):
 +        qs = NullableJSONModel.objects.filter(value__h=True)
 +        tests = [
 +            ('value__h', True),
 +            ('value__i', False),
 +        ]
 +        for lookup, expected in tests:
 +            with self.subTest(lookup=lookup):
 +                self.assertIs(qs.values_list(lookup, flat=True).get(),
 expected)
 +
      @skipUnlessDBFeature('supports_json_field_contains')
      def test_key_contains(self):
 
self.assertIs(NullableJSONModel.objects.filter(value__foo__contains='ar').exists(),
 False)
 }}}

 Related to #27481 and #32203.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32483#comment:3>
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/072.9406945b9b9c1969811d43be0e818c44%40djangoproject.com.

Reply via email to