Mercurial > hg > monetdb-perl
comparison DBD/t/11prep.t @ 26:a0b0ed79f8ab
Move tests for Bugs 2885, 2889, 2897 and 3235 from main repo to here
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Tue, 15 Dec 2020 15:05:24 +0100 (2020-12-15) |
parents | 8c8bd15f7a0b |
children |
comparison
equal
deleted
inserted
replaced
25:154519984d9b | 26:a0b0ed79f8ab |
---|---|
8 | 8 |
9 $| = 1; | 9 $| = 1; |
10 | 10 |
11 use strict; | 11 use strict; |
12 use warnings; | 12 use warnings; |
13 use Data::Dumper; | |
13 use DBI(); | 14 use DBI(); |
14 use DBD_TEST(); | 15 use DBD_TEST(); |
15 | 16 |
16 use Test::More; | 17 use Test::More; |
17 | 18 |
18 if (defined $ENV{DBI_DSN}) { | 19 if (defined $ENV{DBI_DSN}) { |
19 plan tests => 15; | 20 plan tests => 19; |
20 } else { | 21 } else { |
21 plan skip_all => 'Cannot test without DB info'; | 22 plan skip_all => 'Cannot test without DB info'; |
22 } | 23 } |
23 | 24 |
24 pass('Simple prepare/execute/finish tests'); | 25 pass('Simple prepare/execute/finish tests'); |
40 pass('Database connection created'); | 41 pass('Database connection created'); |
41 { | 42 { |
42 local $dbh->{PrintError} = 0; | 43 local $dbh->{PrintError} = 0; |
43 local $dbh->{RaiseError} = 1; | 44 local $dbh->{RaiseError} = 1; |
44 ok( !eval{ $dbh->do("DROP TABLE $tbl") },"DROP TABLE $tbl"); | 45 ok( !eval{ $dbh->do("DROP TABLE $tbl") },"DROP TABLE $tbl"); |
45 print $@, "\n"; | 46 ok( $@ =~ /no such table/, "DROP TABLE failed for the right reason"); |
46 } | 47 } |
47 ok( $dbh->do("CREATE TABLE $tbl( chr char( 1 ) )"),"CREATE TABLE $tbl"); | 48 ok( $dbh->do("CREATE TABLE $tbl( chr char( 1 ) )"),"CREATE TABLE $tbl"); |
48 | 49 |
49 my $sth; | 50 my $sth; |
50 ok( $sth = $dbh->prepare("SELECT * FROM $tbl"),"SELECT * FROM $tbl"); | 51 ok( $sth = $dbh->prepare("SELECT * FROM $tbl"),"SELECT * FROM $tbl"); |
57 #ok( $sth = $dbh->prepare("SELECT * FROM $tbl", { monetdb_ => ... } ),"SELECT * FROM $tbl ( monetdb_ => ... )"); | 58 #ok( $sth = $dbh->prepare("SELECT * FROM $tbl", { monetdb_ => ... } ),"SELECT * FROM $tbl ( monetdb_ => ... )"); |
58 #ok( $sth->execute,'Execute'); | 59 #ok( $sth->execute,'Execute'); |
59 #ok( !( $sth = undef ),'Set sth to undefined'); | 60 #ok( !( $sth = undef ),'Set sth to undefined'); |
60 ok( $dbh->do("DROP TABLE $tbl"),"DROP TABLE $tbl"); | 61 ok( $dbh->do("DROP TABLE $tbl"),"DROP TABLE $tbl"); |
61 | 62 |
63 # Bug 3235 | |
64 ok( $sth = $dbh->prepare("SELECT 0"), "SELECT 0"); | |
65 ok( $sth->execute, 'Execute'); | |
66 my $res = $sth->fetchall_arrayref; | |
67 $Data::Dumper::Terse = 1; # don't output names where feasible | |
68 my $dumped = Dumper($res); | |
69 $dumped =~ s/\s+/ /gm; | |
70 ok( $res->[0]->[0] == 0, "yields $dumped"); | |
71 | |
62 ok( $dbh->disconnect,'Disconnect'); | 72 ok( $dbh->disconnect,'Disconnect'); |