[Dbix-class] Getting numeric columns as numeric values

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Sun Apr 26 22:04:45 GMT 2015


"Martin J. Evans" <martin.evans at easysoft.com> writes:

> On 27/02/15 09:19, Peter Rabbitson wrote:
>> On 02/27/2015 10:10 AM, Martin J. Evans wrote:
>>>
>>> When I came across this problem (not using DBIC) we started adding 0 to
>>> every numeric column when it was fetched but that became a pain. Then,
>>> with Tim's help I added
>>>
>>> http://search.cpan.org/~timb/DBI-1.633/DBI.pm#sql_type_cast
>>>
>>> http://search.cpan.org/~timb/DBI-1.633/DBI.pm#bind_col
>>> StrictlyTyped and DiscardString
>>
>> Hi Martin,
>>
>> Even though I've seen them when scrolling through changelogs, I've
>> completely forgotten about these options, thanks for reminding me!
>>
>> I'll investigate in the future if this can be better incorporated
>> into how DBIC does things. Thanks!
>
> Unfortunately for you, AFAIK, only DBD::ODBC and DBD::Oracle ever
> added support for them (i.e., support for attributes in bind_col and
> actually calling sql_type_cast internally) - principally, because
> those were the only drivers I needed it in.

Just FYI: DBD::Pg will automatically return integers as plain IVs
without a string component, and as of the next version it will do that
with bigints as well if your IV and long types are big enough.

https://github.com/bucardo/dbdpg/blob/master/dbdimp.c#L3717-3722

-- 
"A disappointingly low fraction of the human race is,
 at any given time, on fire." - Stig Sandbeck Mathisen




More information about the DBIx-Class mailing list