[Dbix-class] DBIx::Class::ResultClass::HashRefInflator and
JSON::XS expanding numbers as strings
Peter Rabbitson
rabbit+dbic at rabbit.us
Fri Mar 15 11:16:57 GMT 2013
On Fri, Mar 15, 2013 at 09:48:13AM +0000, Robert Rothenberg wrote:
> I have a PostgreSQL database that I run queries on, then use
>
> $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
>
> and send [ $rs->all ] to JSON::XS for serialization in a RESTful interface.
>
> It works well, except that numeric values are being translated into strings
> instead of numbers.
>
> This doesn't happen with integers, because I cast the column as "::int" and
> the system just does the right thing. But when I cast numeric columns as
> "::numeric", they still come out as strings.
>
> I'm at the point where I want to write my own HashRefInflator, but I don't
> understand what arguments the inflate_result method expects.
The new trial series [1] (which I *really* hope you've tested [2])
contain new tests [3] describing this particular API in detail.
Additions to the DBIC documentation would be absolutely awesome if you
can provide these as you learn.
Cheers!
[1] http://lists.scsys.co.uk/pipermail/dbix-class/2013-February/011109.html
[2] https://twitter.com/dbix_class/status/310776127885041664
[3] https://github.com/dbsrgits/dbix-class/blob/topic/constructor_rewrite/t/resultset/inflate_result_api.t
More information about the DBIx-Class
mailing list