Annotate every indirect sugar-method
[dbsrgits/DBIx-Class.git] / t / cdbi / testlib / MyBase.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 MyBase;
ea2e61bf 3
4a233f30 4use warnings;
ea2e61bf 5use strict;
4a233f30 6
d2cee1fa 7use DBI;
8d6b1478 8use DBICTest;
9
10use base qw(DBIx::Class::CDBICompat);
11
9381840d 12my @connect = (@ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}, { PrintError => 0});
8d6b1478 13# this is only so we grab a lock on mysql
14{
15 my $x = DBICTest::Schema->connect(@connect);
16}
17
83eef562 18our $dbh = DBI->connect(@connect) or die DBI->errstr;
ea2e61bf 19my @table;
20
961d79db 21END {
22 $dbh->do("DROP TABLE $_") for @table;
23 undef $dbh;
24}
ea2e61bf 25
26__PACKAGE__->connection(@connect);
27
28sub set_table {
6a3bf251 29 my $class = shift;
30 $class->table($class->create_test_table);
ea2e61bf 31}
32
33sub create_test_table {
6a3bf251 34 my $self = shift;
35 my $table = $self->next_available_table;
36 my $create = sprintf "CREATE TABLE $table ( %s )", $self->create_sql;
37 push @table, $table;
38 $dbh->do($create);
39 return $table;
ea2e61bf 40}
41
42sub next_available_table {
6a3bf251 43 my $self = shift;
44 my @tables = sort @{
45 $dbh->selectcol_arrayref(
46 qq{
ea2e61bf 47 SHOW TABLES
48 }
6a3bf251 49 )
50 };
51 my $table = $tables[-1] || "aaa";
52 return "z$table";
ea2e61bf 53}
54
551;