Opened 4 years ago

Closed 4 years ago

#32015 closed Bug (duplicate)

psycopg2 jsonb is not loaded with connections.cursor — at Version 2

Reported by: Matt Buck Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords: psycopg2, database, postgresql, json, jsonb, jsonfield
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

Since the upgrade from v3->v3.1, I discovered this regression in the psycopg2 cursor. jsonb results from sql queries are not loaded into python data structures. This causes issues when dumping and loading again, the json fields do not get loaded on the front. The offending line of code can be found here https://github.com/django/django/blob/master/django/db/backends/postgresql/base.py#L206 in the postgresql backend.

This code was introduced to work around issues with specifying a JSONDecoder in the new JSONField. Attempting to implement a workaround by creating additional connections sort of works, but causes freezing during cleanup of test cases, and maybe more serious issues elsewhere.

This is also causing issues with a ValuesQuerySet, the output from jsonb fields is always string.

Change History (2)

comment:1 by Matt Buck, 4 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 4 years ago

Component: UncategorizedDatabase layer (models, ORM)
Description: modified (diff)
Resolution: duplicate
Status: newclosed
Summary: BUG: psycopg2 json is not loaded with connections.cursorpsycopg2 jsonb is not loaded with connections.cursor
Type: UncategorizedBug

Since the upgrade from v3->v3.1, I discovered this regression in the psycopg2 cursor. jsonb results from sql queries are not loaded into python data structures.

This is an intended change, see #31991.

This causes issues when dumping and loading again, the json fields do not get loaded on the front.

I cannot reproduce any issue with dumpdata/loaddata.

This is also causing issues with a ValuesQuerySet, the output from jsonb fields is always string.

Using QuerySet.values() works for me.

Duplicate of #31991. I'm happy to reopen if you can provide a sample project that reproduce described issues with builtin mechanisms.

Note: See TracTickets for help on using tickets.
Back to Top