3 use dbixcsl_common_tests;
6 my $dsn = $ENV{DBICTEST_MYSQL_DSN} || '';
7 my $user = $ENV{DBICTEST_MYSQL_USER} || '';
8 my $password = $ENV{DBICTEST_MYSQL_PASS} || '';
9 my $test_innodb = $ENV{DBICTEST_MYSQL_INNODB} || 0;
11 my $skip_rels_msg = 'You need to set the DBICTEST_MYSQL_INNODB environment variable to test relationships';
13 my $tester = dbixcsl_common_tests->new(
15 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT',
16 innodb => $test_innodb ? q{Engine=InnoDB} : 0,
19 password => $password,
20 connect_info_opts=> { on_connect_call => 'set_strict_mode' },
21 skip_rels => $test_innodb ? 0 : $skip_rels_msg,
23 no_implicit_rels => 1,
27 CREATE TABLE mysql_loader_test1 (
28 id INTEGER UNSIGNED NOT NULL PRIMARY KEY,
29 value ENUM('foo', 'bar', 'baz')
33 CREATE TABLE mysql_loader_test2 (
34 id INTEGER UNSIGNED NOT NULL PRIMARY KEY,
35 somedate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
36 somestr VARCHAR(100) NOT NULL DEFAULT 'foo'
40 drop => [ qw/ mysql_loader_test1 mysql_loader_test2 / ],
43 my ($schema, $monikers, $classes) = @_;
45 my $rs = $schema->resultset($monikers->{mysql_loader_test1});
46 my $column_info = $rs->result_source->column_info('id');
48 is($column_info->{extra}->{unsigned}, 1, 'Unsigned MySQL columns');
50 $column_info = $rs->result_source->column_info('value');
52 like($column_info->{data_type}, qr/^enum$/i, 'MySQL ENUM type');
53 is_deeply($column_info->{extra}->{list}, [qw/foo bar baz/],
56 $rs = $schema->resultset($monikers->{mysql_loader_test2});
57 $column_info = $rs->result_source->column_info('somedate');
58 my $default = $column_info->{default_value};
59 ok ((ref($default) eq 'SCALAR'),
60 'CURRENT_TIMESTAMP default_value is a scalar ref');
61 like $$default, qr/^CURRENT_TIMESTAMP\z/i,
62 'CURRENT_TIMESTAMP default eq "CURRENT_TIMESTAMP"';
67 if( !$dsn || !$user ) {
68 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');