DBD-SQLite
view release on metacpan or search on metacpan
t/20_blobs.t view on Meta::CPAN
2345678910111213141516171819202122# is expected to work correctly.
use
strict;
use
warnings;
use
SQLiteTest;
use
Test::More;
use
if
-d
".git"
,
"Test::FailWarnings"
;
sub
ShowBlob($) {
my
(
$blob
) =
@_
;
(
"showblob length: "
,
length
(
$blob
),
"\n"
);
if
(
$ENV
{SHOW_BLOBS}) {
open
(OUT,
">>$ENV{SHOW_BLOBS}"
) }
my
$i
= 0;
while
(1) {
if
(
defined
(
$blob
) &&
length
(
$blob
) > (
$i
*32)) {
$b
=
substr
(
$blob
,
$i
*32);
}
else
{
$b
=
""
;
last
;
t/48_bind_param_is_sticky.t view on Meta::CPAN
141516171819202122232425262728293031323334
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]);
( run in 0.280 second using v1.01-cache-2.11-cpan-bb97c1e446a )