mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-08 14:48:32 -04:00
DBD-SQLite: does the same for the test for #29058
This commit is contained in:
parent
a35b4bee85
commit
213155f32e
1 changed files with 30 additions and 7 deletions
|
@ -6,8 +6,9 @@ BEGIN {
|
||||||
$^W = 1;
|
$^W = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
use Test::More tests => 12;
|
use Test::More tests => 16;
|
||||||
use t::lib::Test;
|
use t::lib::Test;
|
||||||
|
use DBI qw(:sql_types);
|
||||||
|
|
||||||
my $dbh = connect_ok();
|
my $dbh = connect_ok();
|
||||||
|
|
||||||
|
@ -29,9 +30,13 @@ is ( $sth->fetchrow_arrayref->[0], 17, 'select length result' );
|
||||||
my $statement = 'select count(*) from artist where length(name) > ?';
|
my $statement = 'select count(*) from artist where length(name) > ?';
|
||||||
|
|
||||||
# ...not with bind args
|
# ...not with bind args
|
||||||
$sth = $dbh->prepare($statement);
|
TODO: {
|
||||||
ok ( $sth->execute(2), "execute: $statement : [2]" );
|
local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
|
||||||
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement : [2]" );
|
$sth = $dbh->prepare($statement);
|
||||||
|
ok ( $sth->execute(2), "execute: $statement : [2]" );
|
||||||
|
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement : [2]" );
|
||||||
|
}
|
||||||
|
|
||||||
# ...works without bind args, though!
|
# ...works without bind args, though!
|
||||||
$statement =~ s/\?/2/;
|
$statement =~ s/\?/2/;
|
||||||
$sth = $dbh->prepare($statement);
|
$sth = $dbh->prepare($statement);
|
||||||
|
@ -50,7 +55,25 @@ ok ( $sth->execute, "execute: $statement" );
|
||||||
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement" );
|
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement" );
|
||||||
|
|
||||||
# (...but still not with bind args)
|
# (...but still not with bind args)
|
||||||
$statement =~ s/1/?/;
|
TODO: {
|
||||||
|
local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
|
||||||
|
$statement =~ s/1/?/;
|
||||||
|
$sth = $dbh->prepare($statement);
|
||||||
|
ok ( $sth->execute(1), "execute: $statement : [1]" );
|
||||||
|
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement [1]" );
|
||||||
|
}
|
||||||
|
|
||||||
|
# known workarounds 1: use bind_param explicitly
|
||||||
|
|
||||||
$sth = $dbh->prepare($statement);
|
$sth = $dbh->prepare($statement);
|
||||||
ok ( $sth->execute(1), "execute: $statement : [1]" );
|
$sth->bind_param(1, 2, { TYPE => SQL_INTEGER });
|
||||||
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement [1]" );
|
ok ( $sth->execute, "execute: $statement : [2]" );
|
||||||
|
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement : [2]" );
|
||||||
|
|
||||||
|
# known workarounds 2: add "+0" to let sqlite convert the binded param into number
|
||||||
|
|
||||||
|
$statement =~ s/\?/\?\+0/;
|
||||||
|
$sth = $dbh->prepare($statement);
|
||||||
|
ok ( $sth->execute(2), "execute: $statement : [2]" );
|
||||||
|
is ( $sth->fetchrow_arrayref->[0], 1, "result of: $statement : [2]" );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue