Author: mjevans
Date: Wed Dec 9 00:48:20 2009
New Revision: 13658
Modified:
dbi/trunk/lib/DBI/PurePerl.pm
Log:
In sql_type_cast catch warnings casting a non-numeric type by adding 0 so
we can report the casting failed.
Modified: dbi/trunk/lib/DBI/PurePerl.pm
==============================================================================
--- dbi/trunk/lib/DBI/PurePerl.pm (original)
+++ dbi/trunk/lib/DBI/PurePerl.pm Wed Dec 9 00:48:20 2009
@@ -682,20 +682,29 @@
return -1 unless defined $_[0];
- my $cast_ok = 0;
+ my $cast_ok = 1;
- if ($sql_type == SQL_INTEGER) {
- my $dummy = $_[0] + 0;
- }
- elsif ($sql_type == SQL_DOUBLE) {
- my $dummy = $_[0] + 0.0;
- }
- elsif ($sql_type == SQL_NUMERIC) {
- my $dummy = $_[0] + 0.0;
- }
- else {
- return -2;
- }
+ my $evalret = eval {
+ use warnings FATAL => qw(numeric);
+ if ($sql_type == SQL_INTEGER) {
+ my $dummy = $_[0] + 0;
+ return 1;
+ }
+ elsif ($sql_type == SQL_DOUBLE) {
+ my $dummy = $_[0] + 0.0;
+ return 1;
+ }
+ elsif ($sql_type == SQL_NUMERIC) {
+ my $dummy = $_[0] + 0.0;
+ return 1;
+ }
+ else {
+ return -2;
+ }
+ } or warn $@;
+
+ return $evalret if defined($evalret) && ($evalret == -2);
+ $cast_ok = 0 unless $evalret;
# DBIstcf_DISCARD_STRING not supported for PurePerl currently