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