#32213: QuerySet.values()/.values_list() on KeyTransforms return wrong values 
for
double-quoted strings on SQLite and Oracle
-------------------------------------+-------------------------------------
     Reporter:  Sage Abdullah        |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  sqlite oracle json   |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by bcail):

 * cc: bcail (added)


Comment:

 I'm working on a test for this case, and having trouble reproducing it.
 {{{
 diff --git a/tests/model_fields/test_jsonfield.py
 b/tests/model_fields/test_jsonfield.py
 index 2c32d8a4ea..ecc2b9d0d5 100644
 --- a/tests/model_fields/test_jsonfield.py
 +++ b/tests/model_fields/test_jsonfield.py
 @@ -611,6 +611,11 @@ class TestQuerying(TestCase):
                      [obj],
                  )

 +    def test_value(self):
 +        obj = NullableJSONModel.objects.create(value={"key": '"value"'})
 +
 
self.assertSequenceEqual(NullableJSONModel.objects.filter(value__key='"value"').values_list("value",
 flat=True), [{'key': '"value"'}])
 +
 
self.assertSequenceEqual(NullableJSONModel.objects.filter(Q(value__has_key="key")).values_list("value",
 flat=True), [{'key': '"value"'}])
 +
      @skipUnlessDBFeature("supports_json_field_contains")
      def test_contains(self):
          tests = [
 }}}
 This test passes on both SQLite and Postgresql for me. What do I need to
 change to trigger the wrong behavior?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32213#comment:4>
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/01070183b32a546b-d88a61db-02a5-4828-aa83-cee980ff3916-000000%40eu-central-1.amazonses.com.

Reply via email to