2.2.* to 3.2.5 update: jsonb deserialisation is broken!

24 views
Skip to first unread message

Tim Richardson

unread,
Aug 1, 2021, 10:04:59 AM8/1/21
to Django users
Database is postgresql 12
 psycopg2-binary==2.8.6 \

The bug occurs when I move from django 2.2.* to 3.2.5
A raw sql query is now behaving differently. A result that was previously deserialised from a jsonb field into a python dict now returns a string (and breaks things).

this is a simplifed version of my query:

 sql = """select
    jsonb_array_elements(cached_dear_dearcache.jdata#>'{Fulfilments}')->'Pick' as picks
    from cached_dear_dearcache
     """

jdata is a jsonb field.

picks should be a dict, eg
{"Lines":[{...line1...},{...line2...}]

this has always worked; this django project has always been on 2.2.x
I use this code in production on a variety of postgresql datbase from v 9.6 to v12.

As soon as I update to 3.2.5, I no longer get a dict. Instead, I get a string which is json.

I have downgraded to 2.2 since this is major problem.

Is it a bug or have I missed something?


Jason

unread,
Aug 1, 2021, 7:47:34 PM8/1/21
to Django users
going from 2.2.x to 3.2 is three separate releases of django.  That's alot to go in one jump.  Might help if you update one release at a time and narrow down which version this regression is in.  

In addition, I'd check the changelogs for each version and see what, if any, might apply to your issue.
Reply all
Reply to author
Forward
0 new messages