On Tue, Sep 25, 2012 at 09:18:30AM -0400, Andrew Dunstan wrote:
> >I'm not at all familiar with record_to_json or the json datatype,
> >but wouldn't it be appropriate to create a cast from hstore to
> >json to handle that case?
>
> No, the difficulty (or at least the first difficulty) is in having
> the code recognize that it has an hstore at all. The code picks
> apart the record field by field at run time and takes various
> actions depending on the field's type. For any type it doesn't
> recognize it just outputs the value as a string, and so that's what
> it does with hstore. Mostly this is the right thing but in the
> hstore case it's rather sad.
Is there a particular reason to special case hstore though? Wouldn't it
be sufficient to simply look for a cast from the given type oid to json
and use that if present.
If you don't like cast, allow other extensions to define a function
to_json_hook(yourtype) -> json which is used.
Hardcoding IDs in extensions just doesn't seem right somehow...
(Hmm, I see someone else in the thread pointed this out too).
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts. -- Arthur Schopenhauer