Two failing multicreate tests (the root cause of castaway's problem)
[dbsrgits/DBIx-Class-Historic.git] / t / testlib / MyBase.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 MyBase;
ea2e61bf 3
4use strict;
d2cee1fa 5use base qw(DBIx::Class::CDBICompat);
6
7use DBI;
ea2e61bf 8
9use vars qw/$dbh/;
10
11my @connect = ("dbi:mysql:test", "", "");
12
13$dbh = DBI->connect(@connect) or die DBI->errstr;
14my @table;
15
16END { $dbh->do("DROP TABLE $_") foreach @table }
17
18__PACKAGE__->connection(@connect);
19
20sub set_table {
21 my $class = shift;
22 $class->table($class->create_test_table);
23}
24
25sub create_test_table {
26 my $self = shift;
27 my $table = $self->next_available_table;
28 my $create = sprintf "CREATE TABLE $table ( %s )", $self->create_sql;
29 push @table, $table;
30 $dbh->do($create);
31 return $table;
32}
33
34sub next_available_table {
35 my $self = shift;
36 my @tables = sort @{
37 $dbh->selectcol_arrayref(
38 qq{
39 SHOW TABLES
40 }
41 )
42 };
43 my $table = $tables[-1] || "aaa";
44 return "z$table";
45}
46
471;