Fix incorrect > vs >= ver. check, causing 5.13.1 fails
[dbsrgits/DBIx-Class.git] / t / cdbi / 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
9381840d 11my @connect = (@ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}, { PrintError => 0});
ea2e61bf 12$dbh = DBI->connect(@connect) or die DBI->errstr;
13my @table;
14
15END { $dbh->do("DROP TABLE $_") foreach @table }
16
17__PACKAGE__->connection(@connect);
18
19sub set_table {
6a3bf251 20 my $class = shift;
21 $class->table($class->create_test_table);
ea2e61bf 22}
23
24sub create_test_table {
6a3bf251 25 my $self = shift;
26 my $table = $self->next_available_table;
27 my $create = sprintf "CREATE TABLE $table ( %s )", $self->create_sql;
28 push @table, $table;
29 $dbh->do($create);
30 return $table;
ea2e61bf 31}
32
33sub next_available_table {
6a3bf251 34 my $self = shift;
35 my @tables = sort @{
36 $dbh->selectcol_arrayref(
37 qq{
ea2e61bf 38 SHOW TABLES
39 }
6a3bf251 40 )
41 };
42 my $table = $tables[-1] || "aaa";
43 return "z$table";
ea2e61bf 44}
45
461;