From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Tobias Oberstein <tobias(dot)oberstein(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: JSON type caster |
Date: | 2012-09-18 20:24:44 |
Message-ID: | CA+mi_8bT4CgQPgXg+6=1Q=65-gMAWZWHZ4Jy+uLCwfb6y2LrBA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Tue, Sep 18, 2012 at 9:12 PM, Tobias Oberstein
<tobias(dot)oberstein(at)gmail(dot)com> wrote:
> If there is no other "default mapping" of Python dicts to any other
> PG type, that would make a nice fallback that probably allows to handle
> a lot of situations automatically - such as stored procs that expect
> their JSON args to be dicts anyway.
I think it can be easily done: currently there's no default adaptation
for dicts: there is the hstore adapter but it must be registered
manually.
If we have the Json wrapper, I suspect adapting dicts would be just a matter of:
register_adapter(dict, Json)
it would work with lists and other objects as well, but overriding the
default adapter (e.g. lists to arrays etc.). Because adapters are
currently global this may result in unwanted side effects.
It is definitely an use case to be mentioned in the docs.
Cheers,
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2012-09-19 03:35:45 | Re: JSON type caster |
Previous Message | Tobias Oberstein | 2012-09-18 20:16:49 | Re: JSON type caster |