[Dbix-class] Getting numeric columns as numeric values
Peter Rabbitson
rabbit+dbic at rabbit.us
Thu Feb 26 13:35:22 GMT 2015
On 02/26/2015 09:57 AM, Tim Bunce wrote:
> On Wed, Feb 25, 2015 at 01:15:12PM -0800, Augustus Saunders wrote:
>> For reasons unknown to us, DBIx is stringifying numeric values somewhere along the way.
>
> In addition to the other points made on this thread...
>
> When working on WebAPI::DBIC I found that Cpanel::JSON::XS was the only
> JSON serializer to handle dual-vars (eg stringified numbers) correctly.
>
> Per https://metacpan.org/pod/Cpanel::JSON::XS#cPanel-fork
>
> "fixed encode of numbers for dual-vars. Different string
> representations are preserved, but numbers with temporary strings
> which represent the same number are here treated as numbers,
> not strings. Cpanel::JSON::XS is a bit slower, but preserves
> numeric types better."
>
Mojo::JSON does it as well. Fundamentally this is yet again a
performance tradeoff. The logic as seen from PP-space can be seen here:
https://github.com/kraih/mojo/blob/v5.82/lib/Mojo/JSON.pm#L255-L259
More information about the DBIx-Class
mailing list