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