From: Peter Rabbitson Date: Sat, 12 Oct 2013 12:40:30 +0000 (+0200) Subject: Fix exceedingly sloppy SQLite warning workaround from 04ab4eb1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1363f0f5;p=dbsrgits%2FDBIx-Class-Historic.git Fix exceedingly sloppy SQLite warning workaround from 04ab4eb1 The previous version managed not only to *not* silence any warning but also break the test checking for lack of said warnings. In addition the silencing regex was unacceptably broad, possibly missing some important misbinds. riba pull your shit together man a.k.a. this is what happens when there are no code reviewers :((( --- diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index 03fa8cf..a1a84c0 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -256,18 +256,24 @@ sub bind_attribute_by_data_type { # FIXME - what the flying fuck... work around RT#76395 # DBD::SQLite warns on binding >32 bit values with 32 bit IVs sub _dbh_execute { - if (DBIx::Class::_ENV_::IV_SIZE < 8) { - - if (! defined $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT) { - $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT = ( - modver_gt_or_eq('DBD::SQLite', '1.37') - ) ? 1 : 0; - } - - local $SIG{__WARN__} = sigwarn_silencer( qr/datatype mismatch/ ) - if $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT; + if ( + DBIx::Class::_ENV_::IV_SIZE < 8 + and + ! defined $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT + ) { + $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT = ( + modver_gt_or_eq('DBD::SQLite', '1.37') + ) ? 1 : 0; } + local $SIG{__WARN__} = sigwarn_silencer( qr/ + \Qdatatype mismatch: bind\E \s (?: + param \s+ \( \d+ \) \s+ [-+]? \d+ (?: \. 0*)? \Q as integer\E + | + \d+ \s type \s @{[ DBI::SQL_BIGINT() ]} \s as \s [-+]? \d+ (?: \. 0*)? + ) + /x ) if DBIx::Class::_ENV_::IV_SIZE < 8 and $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT; + shift->next::method(@_); } diff --git a/t/752sqlite.t b/t/752sqlite.t index 8882846..20f9f43 100644 --- a/t/752sqlite.t +++ b/t/752sqlite.t @@ -195,13 +195,12 @@ for my $bi ( qw( my $v_desc = sprintf '%s (%d bit signed int)', $bi, $v_bits; - my $w; + my @w; + local $SIG{__WARN__} = sub { $_[0] =~ /datatype mismatch/ ? push @w, @_ : warn @_ }; + lives_ok { - local $SIG{__WARN__} = sigwarn_silencer( qr/datatype mismatch/ ); $row = $schema->resultset('BigIntArtist')->create({ bigint => $bi }); - } "Insering value $bi ($v_desc)" or next; - - is ($w, undef, 'No mismatch warning on bigints' ); + } "Insering value ($v_desc)" or next; # explicitly using eq, to make sure we did not nummify the argument # which can be an issue on 32 bit ivsize @@ -224,6 +223,8 @@ for my $bi ( qw( "value in database correct ($v_desc)" ); + + is_deeply (\@w, [], 'No mismatch warnings on bigint operations' ); } done_testing;