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,
24 no_implicit_rels => 1,
26 # http://dev.mysql.com/doc/refman/5.5/en/data-type-overview.html
28 'bit' => { data_type => 'bit', size => 1 },
29 'bit(11)' => { data_type => 'bit', size => 11 },
31 'bool' => { data_type => 'tinyint' },
32 'boolean' => { data_type => 'tinyint' },
33 'tinyint' => { data_type => 'tinyint' },
35 => { data_type => 'tinyint', extra => { unsigned => 1 } },
36 'smallint' => { data_type => 'smallint' },
38 => { data_type => 'smallint', extra => { unsigned => 1 } },
39 'mediumint' => { data_type => 'mediumint' },
41 => { data_type => 'mediumint', extra => { unsigned => 1 } },
42 'int' => { data_type => 'integer' },
44 => { data_type => 'integer', extra => { unsigned => 1 } },
45 'integer' => { data_type => 'integer' },
47 => { data_type => 'integer', extra => { unsigned => 1 } },
49 => { data_type => 'integer' },
50 'bigint' => { data_type => 'bigint' },
52 => { data_type => 'bigint', extra => { unsigned => 1 } },
54 'serial' => { data_type => 'bigint', is_auto_increment => 1, extra => { unsigned => 1 } },
56 'float' => { data_type => 'float' },
58 => { data_type => 'float', extra => { unsigned => 1 } },
59 'double' => { data_type => 'double precision' },
61 => { data_type => 'double precision', extra => { unsigned => 1 } },
63 { data_type => 'double precision' },
64 'double precision unsigned'
65 => { data_type => 'double precision', extra => { unsigned => 1 } },
67 # we skip 'real' because its alias depends on the 'REAL AS FLOAT' setting
69 'float(2)' => { data_type => 'float' },
70 'float(24)' => { data_type => 'float' },
71 'float(25)' => { data_type => 'double precision' },
73 'float(3,3)' => { data_type => 'float', size => [3,3] },
74 'double(3,3)' => { data_type => 'double precision', size => [3,3] },
75 'double precision(3,3)'
76 => { data_type => 'double precision', size => [3,3] },
78 'decimal' => { data_type => 'decimal' },
80 => { data_type => 'decimal', extra => { unsigned => 1 } },
81 'dec' => { data_type => 'decimal' },
82 'numeric' => { data_type => 'decimal' },
83 'fixed' => { data_type => 'decimal' },
85 'decimal(3)' => { data_type => 'decimal', size => [3,0] },
87 'decimal(3,3)' => { data_type => 'decimal', size => [3,3] },
88 'dec(3,3)' => { data_type => 'decimal', size => [3,3] },
89 'numeric(3,3)' => { data_type => 'decimal', size => [3,3] },
90 'fixed(3,3)' => { data_type => 'decimal', size => [3,3] },
93 'date' => { data_type => 'date', datetime_undef_if_invalid => 1 },
94 'datetime' => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
95 'timestamp default current_timestamp'
96 => { data_type => 'timestamp', default_value => \'current_timestamp', datetime_undef_if_invalid => 1 },
97 'time' => { data_type => 'time' },
98 'year' => { data_type => 'year' },
99 'year(4)' => { data_type => 'year' },
100 'year(2)' => { data_type => 'year', size => 2 },
103 'char' => { data_type => 'char', size => 1 },
104 'char(11)' => { data_type => 'char', size => 11 },
105 'varchar(20)' => { data_type => 'varchar', size => 20 },
106 'binary' => { data_type => 'binary', size => 1 },
107 'binary(11)' => { data_type => 'binary', size => 11 },
108 'varbinary(20)'=> { data_type => 'varbinary', size => 20 },
110 'tinyblob' => { data_type => 'tinyblob' },
111 'tinytext' => { data_type => 'tinytext' },
112 'blob' => { data_type => 'blob' },
114 # text(M) types will map to the appropriate type, length is not stored
115 'text' => { data_type => 'text' },
117 'mediumblob' => { data_type => 'mediumblob' },
118 'mediumtext' => { data_type => 'mediumtext' },
119 'longblob' => { data_type => 'longblob' },
120 'longtext' => { data_type => 'longtext' },
122 "enum('foo','bar','baz')"
123 => { data_type => 'enum', extra => { list => [qw/foo bar baz/] } },
124 "set('foo','bar','baz')"
125 => { data_type => 'set', extra => { list => [qw/foo bar baz/] } },
130 CREATE TABLE mysql_loader_test1 (
131 id INT AUTO_INCREMENT PRIMARY KEY,
136 CREATE VIEW mysql_loader_test2 AS SELECT * FROM mysql_loader_test1
139 pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
140 drop => [ 'mysql_loader_test1', ],
143 my ($schema, $monikers, $classes) = @_;
145 my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
147 is $rsrc->column_info('value')->{data_type}, 'varchar',
148 'view introspected successfully';
153 if( !$dsn || !$user ) {
154 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');
157 diag $skip_rels_msg if not $test_innodb;
158 $tester->run_tests();
161 # vim:et sts=4 sw=4 tw=0: