| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More; |
| 6 |
|
| 7 |
BEGIN { use_ok ("DBI"); } |
| 8 |
do "./t/lib.pl"; |
| 9 |
|
| 10 |
sub DbFile; |
| 11 |
|
| 12 |
my $dir = DbDir (); |
| 13 |
|
| 14 |
my @tbl_def = ( |
| 15 |
[ "id", "INTEGER", 4, 0 ], |
| 16 |
[ "name", "CHAR", 64, 0 ], |
| 17 |
); |
| 18 |
|
| 19 |
my $tbl = "foo"; |
| 20 |
ok (my $dbh = Connect (), "connect"); |
| 21 |
ok (!-f DbFile ($tbl), "foo does not exist"); |
| 22 |
ok ($dbh->{ignore_missing_table} = 1, "ignore missing tables"); |
| 23 |
|
| 24 |
like (my $def = TableDefinition ($tbl, @tbl_def), |
| 25 |
qr{^create table $tbl}i, "table definition"); |
| 26 |
ok ($dbh->do ($def), "create table"); |
| 27 |
ok (-f DbFile ($tbl), "does exists"); |
| 28 |
|
| 29 |
for (qw( foo foO fOo fOO Foo FoO FOo FOO )) { |
| 30 |
ok (my $sth = $dbh->prepare ("select * from $_"), "select from $_"); |
| 31 |
ok ($sth->execute, "execute"); |
| 32 |
} |
| 33 |
ok ($dbh->disconnect, "disconnect"); |
| 34 |
undef $dbh; |
| 35 |
|
| 36 |
ok ($dbh = Connect (), "connect"); |
| 37 |
ok ($dbh->{ignore_missing_table} = 1, "ignore missing tables"); |
| 38 |
|
| 39 |
my $case_ok = isSaneCase (); |
| 40 |
for (qw( foo foO fOo fOO Foo FoO FOo FOO )) { |
| 41 |
ok (my $sth = $dbh->prepare (qq{select * from "$_"}), "prepare \"$_\""); |
| 42 |
|
| 43 |
if ($_ eq "foo") { |
| 44 |
ok ( $sth->execute, "execute ok"); |
| 45 |
} |
| 46 |
else { |
| 47 |
TODO: { |
| 48 |
local $TODO = "Filesystem has to be case-aware" unless $case_ok; |
| 49 |
local $sth->{PrintError} = 0; |
| 50 |
ok (!$sth->execute, "table name '$_' should not match 'foo'"); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
ok ($dbh->do ("drop table $tbl"), "drop table"); |
| 56 |
|
| 57 |
ok ($dbh->disconnect, "disconnect"); |
| 58 |
undef $dbh; |
| 59 |
|
| 60 |
done_testing (); |