Re: JSON type caster
От | Daniele Varrazzo |
---|---|
Тема | Re: JSON type caster |
Дата | |
Msg-id | CA+mi_8bT4CgQPgXg+6=1Q=65-gMAWZWHZ4Jy+uLCwfb6y2LrBA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: JSON type caster (Tobias Oberstein <tobias.oberstein@gmail.com>) |
Список | psycopg |
On Tue, Sep 18, 2012 at 9:12 PM, Tobias Oberstein <tobias.oberstein@gmail.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
В списке psycopg по дате отправления: