#31991: QuerySet.raw() method returns string instead of dict for JSONField().
-------------------------------------+-------------------------------------
     Reporter:  horpto               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  JSONfield            |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Ruben Nielsen):

 Hello,

 Chiming in here, as this is something that breaks a lot of functionality
 in our app when loading. I'm seeing this particular piece of the code as
 my problem:


 {{{
         # Register dummy loads() to avoid a round trip from psycopg2's
 decode
         # to json.dumps() to json.loads(), when using a custom decoder in
         # JSONField.
         psycopg2.extras.register_default_jsonb(conn_or_curs=connection,
 loads=lambda x: x)
 }}}
 (django.db.backends.postgresql.base.py::DatabaseWrapper.get_new_connection)

 I sort-of understand the reasoning behind this change, but I'm not sure
 how to get around it, if I just want the original functionality for my
 project, which only uses Postgres anyway. The comment says "when using a
 custom decoder", so shouldn't you check for this? If I use one, then fine,
 but if I don't then stop breaking psycopg2 for me... Or could this be
 controlled from settings.py? I know there are tonnes of settings already,
 but it would certainly help.

 Or another path. How do I set a custom decoder for all my JSONFields?
 Earlier, everything was simply `json.loads` by default, so that was all
 good. I know how to make a custom field with a custom decoder, sure, but
 how would I then tie that into `queryset.raw()`?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31991#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/064.fd3521b0093ece74f73779e81f401593%40djangoproject.com.

Reply via email to