[Dbix-class] Getting numeric columns as numeric values

Martin J. Evans martin.evans at easysoft.com
Fri Feb 27 09:27:35 GMT 2015


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.

http://search.cpan.org/~mjevans/DBD-ODBC-1.50/ODBC.pm#Additional_bind_col_attributes
http://search.cpan.org/~pythian/DBD-Oracle-1.74/lib/DBD/Oracle.pm#bind_col

although DBI's sql_type_cast might be useful.

Martin



More information about the DBIx-Class mailing list