1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00
DBD-SQLite-SQLcipher/t/48_bind_param_is_sticky.t
Peter Rabbitson c4eab85ff7 Workaround for upcoming lack of dot in @INC ( RT#120444, sigh )
Zero functional changes, simply executed the following:

find . -name '*.t' -exec perl -0777 -p -i -e 's|^use t::lib::SQLiteTest|use lib "t/lib";\nuse SQLiteTest|m' {} +

Also had to do a manual (but identical) fix in t/01_compile.t
2017-05-05 00:48:33 +02:00

49 lines
1.1 KiB
Perl

#!/usr/bin/perl
# Check data type assignment in bind_param is sticky
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
use lib "t/lib";
use SQLiteTest qw/connect_ok/;
use DBI qw(:sql_types);
use Test::More;
use Test::NoWarnings;
plan tests => 10 + 1;
my $dbh = connect_ok(
RaiseError => 1,
PrintError => 0,
AutoCommit => 0,
);
$dbh->do("CREATE TABLE Blah ( id INTEGER, val BLOB )");
$dbh->commit;
my $sth;
ok($sth = $dbh->prepare("INSERT INTO Blah VALUES (?, ?)"), "prepare");
$sth->bind_param(1, 1);
$sth->bind_param(2, 'foo', SQL_BLOB);
$sth->execute;
$sth->execute(2, 'bar');
sub verify_types() {
my $rows = $dbh->selectall_arrayref("SELECT typeof(val) FROM Blah ORDER BY id");
ok($rows, "selectall_arrayref returned data");
ok(@{$rows} == 2, "... with expected number of rows");
ok($rows->[0]->[0] eq 'blob', "$rows->[0]->[0] eq blob");
ok($rows->[1]->[0] eq 'blob', "$rows->[1]->[0] eq blob");
}
verify_types();
$dbh->commit;
$dbh->do("DELETE FROM Blah");
$sth->bind_param_array(1, [1, 2]);
$sth->bind_param_array(2, [qw/FOO BAR/], SQL_BLOB);
$sth->execute_array({});
verify_types();
$dbh->commit;
$dbh->disconnect;
undef($dbh);