dbdpg icon indicating copy to clipboard operation
dbdpg copied to clipboard

Q: autoJSONify

Open mche opened this issue 8 years ago • 6 comments
trafficstars

Hi!

Let me stupid question. Do you have planned to autoJSONify from Perl data to PG json/jsonb data types and backwards?

Regards.

mche avatar Oct 17 '17 07:10 mche

Yes, it's been on our long-term todo for a while. Not sure when people will have tuits for this: it's a non-trivial task.

turnstep avatar Feb 04 '18 22:02 turnstep

@turnstep are you thinking of rolling-your-own serialization/deserialization, or just hooking into JSON::XS or similar?

machack666 avatar Aug 20 '19 15:08 machack666

We need to do our own parsing regardless, in the same way the arrays are done now. Whether or how to involve JSON::XS is somewhat secondary at the moment.

turnstep avatar Aug 20 '19 15:08 turnstep

JSON is probably the most important type for automatic conversion in DBD::Pg, but not the only one. In some cases users may want to convert NUMERICSs to Math::BigInt or Math::BigFloat; dates/times and composite types also may be converted to something etc.

Do the thing I am thinking about is to allow custom conversion for the data types. A user may be given a possibility to specify converters for the data types (like TRANSFORMS in stored procedures). Something like $dbi->set_transform('jsonb', &JSON::XS::encode_json,&JSON::XS::decode_json) This would be a flexible universal solution.

waaeer avatar Sep 25 '19 20:09 waaeer

That sounds nice in theory, but I'm not sure how that would work in practice. The conversions happen in the Perl XS code, and involve low-level transformations of textual representations of certain types to Perl objects.

turnstep avatar Sep 26 '19 15:09 turnstep

Not sure when people will have tuits for this: it's a non-trivial task.

What areas does the complexity reside in?

ap avatar Mar 04 '22 13:03 ap