1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

All those explicit disconnects are no longer required

This commit is contained in:
Adam Kennedy 2009-04-04 02:54:00 +00:00
parent 140d920c5a
commit 193d8e8f52
11 changed files with 31 additions and 62 deletions

View file

@ -18,5 +18,3 @@ diag("sqlite_version=$dbh->{sqlite_version}");
ok( $dbh->func('busy_timeout'), 'Found initial busy_timeout' );
ok( $dbh->func(5000, 'busy_timeout') );
is( $dbh->func('busy_timeout'), 5000, 'Set busy_timeout to new value' );
$dbh->disconnect;

View file

@ -14,13 +14,9 @@ use t::lib::Test;
my $dbh = connect_ok();
$dbh->do("CREATE TABLE f (f1, f2, f3)");
SCOPE: {
my $sth = $dbh->prepare("SELECT f.f1, f.* FROM f");
isa_ok( $sth, 'DBI::st' );
ok( $sth->execute, '->execute ok' );
my $names = $sth->{NAME};
is( scalar(@$names), 4, 'Got 4 columns' );
is_deeply( $names, [ 'f1', 'f1', 'f2', 'f3' ], 'Table prepending is disabled by default' );
}
$dbh->disconnect;
my $sth = $dbh->prepare("SELECT f.f1, f.* FROM f");
isa_ok( $sth, 'DBI::st' );
ok( $sth->execute, '->execute ok' );
my $names = $sth->{NAME};
is( scalar(@$names), 4, 'Got 4 columns' );
is_deeply( $names, [ 'f1', 'f1', 'f2', 'f3' ], 'Table prepending is disabled by default' );

View file

@ -25,12 +25,10 @@ SCOPE: {
is( $sth->execute("test", "test", "3"), 1 );
SKIP: {
skip( 'last_insert_id requires DBI v1.43', 2 ) if $DBI::VERSION < 1.43;
is( $dbh->last_insert_id(undef, undef, undef, undef), 4 );
is( $dbh->func('last_insert_rowid'), 4, 'last_insert_rowid should be 4' );
skip( 'last_insert_id requires DBI v1.43', 2 ) if $DBI::VERSION < 1.43;
is( $dbh->last_insert_id(undef, undef, undef, undef), 4 );
is( $dbh->func('last_insert_rowid'), 4, 'last_insert_rowid should be 4' );
}
}
is( $dbh->do("delete from f where f1='test'"), 3 );
$dbh->disconnect;

View file

@ -58,6 +58,4 @@ while ($row = $sth->fetch) {
}
ok($num_rows == 1);
$sth->finish;
undef $sth;
$dbh->do("delete from f where f1='test'");
$dbh->disconnect;

View file

@ -27,19 +27,15 @@ $dbh->do("INSERT INTO TRN VALUES('C', 1, 4)");
$dbh->do("INSERT INTO TRN VALUES('D', 3, 3)");
$dbh->rollback; #not work?
SCOPE: {
my $sth = $dbh->prepare(
"SELECT TRN.id AS ID, MST.LBL AS TITLE,
SUM(qty) AS TOTAL FROM TRN,MST
WHERE TRN.ID = MST.ID
GROUP BY TRN.ID ORDER BY TRN.ID DESC");
my $rows = $sth->execute();
ok($rows, "0E0");
my $names = $sth->{NAME};
print(join(', ', @$names), "\n");
while(my $raD = $sth->fetchrow_arrayref()) {
print join(":", @$raD), "\n";
}
my $sth = $dbh->prepare(
"SELECT TRN.id AS ID, MST.LBL AS TITLE,
SUM(qty) AS TOTAL FROM TRN,MST
WHERE TRN.ID = MST.ID
GROUP BY TRN.ID ORDER BY TRN.ID DESC");
my $rows = $sth->execute();
ok($rows, "0E0");
my $names = $sth->{NAME};
print(join(', ', @$names), "\n");
while(my $raD = $sth->fetchrow_arrayref()) {
print join(":", @$raD), "\n";
}
$dbh->disconnect;

View file

@ -115,5 +115,3 @@ is_deeply( $result, [ '' ], "SELECT noop('')" );
$result = $dbh->selectrow_arrayref( "SELECT noop(1.0625)" );
is_deeply( $result, [ 1.0625 ], "SELECT noop(1.0625)" );
$dbh->disconnect;

View file

@ -126,4 +126,3 @@ Test($lengths->[0]->[0] == $lengths->[0]->[1],
warn "($lengths->[0]->[0] != $lengths->[0]->[1])";
$dbh->do("DROP TABLE $table");
$dbh->disconnect;

View file

@ -98,5 +98,3 @@ is_deeply(\@sorted, $db_sorted, "collate perllocale (@sorted // @$db_sorted)");
@sorted = sort no_accents @words_utf8;
$db_sorted = $dbh->selectcol_arrayref("$sql COLLATE no_accents");
is_deeply(\@sorted, $db_sorted, "collate no_accents (@sorted // @$db_sorted)");
$dbh->disconnect;

View file

@ -45,5 +45,3 @@ $result = $dbh->do( "SELECT * from progress_test ORDER BY foo DESC " );
# now the progress handler should have been called zero times
ok(!$n_callback);
$dbh->disconnect;

View file

@ -59,12 +59,6 @@ for (1..5) {
ok(!$sel->fetch);
}
$sel->finish;
undef $sel;
$db->disconnect;
sub dumpblob {
my $blob = shift;
print("# showblob length: ", length($blob), "\n");

View file

@ -24,18 +24,14 @@ $dbh->do("INSERT INTO f VALUES (?, ?, ?)", {}, 'foo', 'bar', 3);
$dbh->do("INSERT INTO f VALUES (?, ?, ?)", {}, 'foo', 'bar', 4);
$dbh->do("INSERT INTO f VALUES (?, ?, ?)", {}, 'foo', 'bar', 5);
SCOPE: {
my $sth1 = $dbh->prepare_cached('SELECT * FROM f ORDER BY f3', {});
isa_ok( $sth1, 'DBI::st' );
ok( $sth1->execute, '->execute ok' );
is_deeply( $sth1->fetchrow_arrayref, [ 'foo', 'bar', 1 ], 'Row 1 ok' );
is_deeply( $sth1->fetchrow_arrayref, [ 'foo', 'bar', 2 ], 'Row 2 ok' );
my $sth2 = $dbh->prepare_cached('SELECT * FROM f ORDER BY f3', {}, 3);
isa_ok( $sth2, 'DBI::st' );
ok( $sth2->execute, '->execute ok' );
is_deeply( $sth2->fetchrow_arrayref, [ 'foo', 'bar', 1 ], 'Row 1 ok' );
is_deeply( $sth2->fetchrow_arrayref, [ 'foo', 'bar', 2 ], 'Row 2 ok' );
ok( $sth2->finish, '->finish ok' );
}
$dbh->disconnect;
my $sth1 = $dbh->prepare_cached('SELECT * FROM f ORDER BY f3', {});
isa_ok( $sth1, 'DBI::st' );
ok( $sth1->execute, '->execute ok' );
is_deeply( $sth1->fetchrow_arrayref, [ 'foo', 'bar', 1 ], 'Row 1 ok' );
is_deeply( $sth1->fetchrow_arrayref, [ 'foo', 'bar', 2 ], 'Row 2 ok' );
my $sth2 = $dbh->prepare_cached('SELECT * FROM f ORDER BY f3', {}, 3);
isa_ok( $sth2, 'DBI::st' );
ok( $sth2->execute, '->execute ok' );
is_deeply( $sth2->fetchrow_arrayref, [ 'foo', 'bar', 1 ], 'Row 1 ok' );
is_deeply( $sth2->fetchrow_arrayref, [ 'foo', 'bar', 2 ], 'Row 2 ok' );
ok( $sth2->finish, '->finish ok' );