4 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 loader_options => { preserve_case => 1 },
22 skip_rels => $test_innodb ? 0 : $skip_rels_msg,
25 no_implicit_rels => 1,
27 # http://dev.mysql.com/doc/refman/5.5/en/data-type-overview.html
29 'bit' => { data_type => 'bit', size => 1 },
30 'bit(11)' => { data_type => 'bit', size => 11 },
32 'bool' => { data_type => 'tinyint' },
33 'boolean' => { data_type => 'tinyint' },
34 'tinyint' => { data_type => 'tinyint' },
36 => { data_type => 'tinyint', extra => { unsigned => 1 } },
37 'smallint' => { data_type => 'smallint' },
39 => { data_type => 'smallint', extra => { unsigned => 1 } },
40 'mediumint' => { data_type => 'mediumint' },
42 => { data_type => 'mediumint', extra => { unsigned => 1 } },
43 'int' => { data_type => 'integer' },
45 => { data_type => 'integer', extra => { unsigned => 1 } },
46 'integer' => { data_type => 'integer' },
48 => { data_type => 'integer', extra => { unsigned => 1 } },
50 => { data_type => 'integer' },
51 'bigint' => { data_type => 'bigint' },
53 => { data_type => 'bigint', extra => { unsigned => 1 } },
55 'serial' => { data_type => 'bigint', is_auto_increment => 1, extra => { unsigned => 1 } },
57 'float' => { data_type => 'float' },
59 => { data_type => 'float', extra => { unsigned => 1 } },
60 'double' => { data_type => 'double precision' },
62 => { data_type => 'double precision', extra => { unsigned => 1 } },
64 { data_type => 'double precision' },
65 'double precision unsigned'
66 => { data_type => 'double precision', extra => { unsigned => 1 } },
68 # we skip 'real' because its alias depends on the 'REAL AS FLOAT' setting
70 'float(2)' => { data_type => 'float' },
71 'float(24)' => { data_type => 'float' },
72 'float(25)' => { data_type => 'double precision' },
74 'float(3,3)' => { data_type => 'float', size => [3,3] },
75 'double(3,3)' => { data_type => 'double precision', size => [3,3] },
76 'double precision(3,3)'
77 => { data_type => 'double precision', size => [3,3] },
79 'decimal' => { data_type => 'decimal' },
81 => { data_type => 'decimal', extra => { unsigned => 1 } },
82 'dec' => { data_type => 'decimal' },
83 'numeric' => { data_type => 'decimal' },
84 'fixed' => { data_type => 'decimal' },
86 'decimal(3)' => { data_type => 'decimal', size => [3,0] },
88 'decimal(3,3)' => { data_type => 'decimal', size => [3,3] },
89 'dec(3,3)' => { data_type => 'decimal', size => [3,3] },
90 'numeric(3,3)' => { data_type => 'decimal', size => [3,3] },
91 'fixed(3,3)' => { data_type => 'decimal', size => [3,3] },
94 'date' => { data_type => 'date', datetime_undef_if_invalid => 1 },
95 'datetime' => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
96 'timestamp default current_timestamp'
97 => { data_type => 'timestamp', default_value => \'current_timestamp', datetime_undef_if_invalid => 1 },
98 'time' => { data_type => 'time' },
99 'year' => { data_type => 'year' },
100 'year(4)' => { data_type => 'year' },
101 'year(2)' => { data_type => 'year', size => 2 },
104 'char' => { data_type => 'char', size => 1 },
105 'char(11)' => { data_type => 'char', size => 11 },
106 'varchar(20)' => { data_type => 'varchar', size => 20 },
107 'binary' => { data_type => 'binary', size => 1 },
108 'binary(11)' => { data_type => 'binary', size => 11 },
109 'varbinary(20)'=> { data_type => 'varbinary', size => 20 },
111 'tinyblob' => { data_type => 'tinyblob' },
112 'tinytext' => { data_type => 'tinytext' },
113 'blob' => { data_type => 'blob' },
115 # text(M) types will map to the appropriate type, length is not stored
116 'text' => { data_type => 'text' },
118 'mediumblob' => { data_type => 'mediumblob' },
119 'mediumtext' => { data_type => 'mediumtext' },
120 'longblob' => { data_type => 'longblob' },
121 'longtext' => { data_type => 'longtext' },
123 "enum('foo','bar','baz')"
124 => { data_type => 'enum', extra => { list => [qw/foo bar baz/] } },
125 "set('foo','bar','baz')"
126 => { data_type => 'set', extra => { list => [qw/foo bar baz/] } },
129 "enum('11,10 (<500)/0 DUN','4,90 (<120)/0 EUR') NOT NULL default '11,10 (<500)/0 DUN'"
130 => { data_type => 'enum', extra => { list => ['11,10 (<500)/0 DUN', '4,90 (<120)/0 EUR'] }, default_value => '11,10 (<500)/0 DUN' },
131 "set('11_10 (<500)/0 DUN','4_90 (<120)/0 EUR') NOT NULL default '11_10 (<500)/0 DUN'"
132 => { data_type => 'set', extra => { list => ['11_10 (<500)/0 DUN', '4_90 (<120)/0 EUR'] }, default_value => '11_10 (<500)/0 DUN' },
138 CREATE TABLE `mysql_loader-test1` (
139 id INT AUTO_INCREMENT PRIMARY KEY,
144 CREATE VIEW mysql_loader_test2 AS SELECT * FROM `mysql_loader-test1`
147 pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
148 drop => [ 'mysql_loader-test1', ],
151 my ($schema, $monikers, $classes) = @_;
153 is $monikers->{'mysql_loader-test1'}, 'MysqlLoaderTest1',
154 'table with dash correctly monikerized';
156 my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
158 is $rsrc->column_info('value')->{data_type}, 'varchar',
159 'view introspected successfully';
164 if( !$dsn || !$user ) {
165 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');
168 diag $skip_rels_msg if not $test_innodb;
169 $tester->run_tests();
172 # vim:et sts=4 sw=4 tw=0: