From: Peter Rabbitson Date: Mon, 1 Apr 2013 09:05:05 +0000 (+0200) Subject: Saner check for non-integer values bound as integers in SQLite X-Git-Tag: v0.08210~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=445bc0cd67d1176df63280ecbb415cd768a7c6df;p=dbsrgits%2FDBIx-Class.git Saner check for non-integer values bound as integers in SQLite --- diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index 14c07d2..c833f86 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -7,7 +7,6 @@ use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; use DBIx::Class::Carp; -use Scalar::Util 'looks_like_number'; use Try::Tiny; use namespace::clean; @@ -217,10 +216,10 @@ sub _dbi_attrs_for_bind { and $bindattrs->[$_] eq DBI::SQL_INTEGER() and - ! looks_like_number ($bind->[$_][1]) + $bind->[$_][1] !~ /^ [\+\-]? [0-9]+ (?: \. 0* )? $/x ) { carp_unique( sprintf ( - "Non-numeric value supplied for column '%s' despite the numeric datatype", + "Non-integer value supplied for column '%s' despite the integer datatype", $bind->[$_][0]{dbic_colname} || "# $_" ) ); undef $bindattrs->[$_]; diff --git a/t/752sqlite.t b/t/752sqlite.t index 1895a9f..1a511f2 100644 --- a/t/752sqlite.t +++ b/t/752sqlite.t @@ -121,7 +121,7 @@ my $schema = DBICTest->init_schema(); # make sure the side-effects of RT#67581 do not result in data loss my $row; warnings_exist { $row = $schema->resultset('Artist')->create ({ name => 'alpha rank', rank => 'abc' }) } - [qr/Non-numeric value supplied for column 'rank' despite the numeric datatype/], + [qr/Non-integer value supplied for column 'rank' despite the integer datatype/], 'proper warning on string insertion into an numeric column' ; $row->discard_changes;