ticket #172  suggests I have been too eager with JSON and Postgres
9.2. The ticket is from an user who just wants to read the json from the
database and forward it to the web clients, so a json -> python
conversion would be just a waste of time. Psycopg 2.5 instead registers
the json adapter on the PG 9.2 oids automatically.
If anybody else finds the same problem and wants to receive json as text
in 9.2 too, the interim solution with psycopg 2.5 and 2.5.1 is the
import psycopg2.extensions as ext
if hasattr(ext, 'JSON'):
Another solution would be of course to cast the result to text instead.
What I would do is to introduce in the next release an unregister_json()
function doing roughly (but less roughly) what this snippet does.
I've taken in consideration the idea of dropping the automatic
registration of the json adapter after giving a few months of warning,
but thinking about that more coolly I think it would be a bad reaction.
The feature was legitimately added on a major release (2.5) and if
somebody finds it broken he can still install the last 2.4 available
(pip install "psycopg2<2.5"). The right moment to think about a
different behaviour (e.g. require register_json() to be called) is the
next major release.
Comments? Better ideas?
psycopg by date
|Next:||From: Christophe Pettus||Date: 2013-07-19 19:02:59|
|Subject: Re: Problem with the default registration of the JSON adapter|
|Previous:||From: Daniele Varrazzo||Date: 2013-06-25 09:55:09|
|Subject: Re: Error in a simple query (SOLVED)|