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 skip_rels => $test_innodb ? 0 : $skip_rels_msg,
23 no_implicit_rels => 1,
25 # http://dev.mysql.com/doc/refman/5.5/en/data-type-overview.html
27 'bit' => { data_type => 'bit', size => 1 },
28 'bit(11)' => { data_type => 'bit', size => 11 },
30 'bool' => { data_type => 'tinyint' },
31 'boolean' => { data_type => 'tinyint' },
32 'tinyint' => { data_type => 'tinyint' },
34 => { data_type => 'tinyint', extra => { unsigned => 1 } },
35 'smallint' => { data_type => 'smallint' },
37 => { data_type => 'smallint', extra => { unsigned => 1 } },
38 'mediumint' => { data_type => 'mediumint' },
40 => { data_type => 'mediumint', extra => { unsigned => 1 } },
41 'int' => { data_type => 'integer' },
43 => { data_type => 'integer', extra => { unsigned => 1 } },
44 'integer' => { data_type => 'integer' },
46 => { data_type => 'integer', extra => { unsigned => 1 } },
47 'bigint' => { data_type => 'bigint' },
49 => { data_type => 'bigint', extra => { unsigned => 1 } },
51 'serial' => { data_type => 'bigint', is_auto_increment => 1, extra => { unsigned => 1 } },
53 'float' => { data_type => 'float' },
55 => { data_type => 'float', extra => { unsigned => 1 } },
56 'double' => { data_type => 'double precision' },
58 => { data_type => 'double precision', extra => { unsigned => 1 } },
60 { data_type => 'double precision' },
61 'double precision unsigned'
62 => { data_type => 'double precision', extra => { unsigned => 1 } },
64 # we skip 'real' because its alias depends on the 'REAL AS FLOAT' setting
66 'float(2)' => { data_type => 'float' },
67 'float(24)' => { data_type => 'float' },
68 'float(25)' => { data_type => 'double precision' },
70 'float(3,3)' => { data_type => 'float', size => [3,3] },
71 'double(3,3)' => { data_type => 'double precision', size => [3,3] },
72 'double precision(3,3)'
73 => { data_type => 'double precision', size => [3,3] },
75 'decimal' => { data_type => 'decimal' },
77 => { data_type => 'decimal', extra => { unsigned => 1 } },
78 'dec' => { data_type => 'decimal' },
79 'numeric' => { data_type => 'decimal' },
80 'fixed' => { data_type => 'decimal' },
82 'decimal(3)' => { data_type => 'decimal', size => [3,0] },
84 'decimal(3,3)' => { data_type => 'decimal', size => [3,3] },
85 'dec(3,3)' => { data_type => 'decimal', size => [3,3] },
86 'numeric(3,3)' => { data_type => 'decimal', size => [3,3] },
87 'fixed(3,3)' => { data_type => 'decimal', size => [3,3] },
90 'date' => { data_type => 'date' },
91 'datetime' => { data_type => 'datetime' },
92 'timestamp DEFAULT current_timestamp'
93 => { data_type => 'timestamp', default_value => \"CURRENT_TIMESTAMP" },
94 'time' => { data_type => 'time' },
95 'year' => { data_type => 'year' },
96 'year(4)' => { data_type => 'year' },
97 'year(2)' => { data_type => 'year', size => 2 },
100 'char' => { data_type => 'char', size => 1 },
101 'char(11)' => { data_type => 'char', size => 11 },
102 'varchar(20)' => { data_type => 'varchar', size => 20 },
103 'binary' => { data_type => 'binary', size => 1 },
104 'binary(11)' => { data_type => 'binary', size => 11 },
105 'varbinary(20)'=> { data_type => 'varbinary', size => 20 },
107 'tinyblob' => { data_type => 'tinyblob' },
108 'tinytext' => { data_type => 'tinytext' },
109 'blob' => { data_type => 'blob' },
111 # text(M) types will map to the appropriate type, length is not stored
112 'text' => { data_type => 'text' },
114 'mediumblob' => { data_type => 'mediumblob' },
115 'mediumtext' => { data_type => 'mediumtext' },
116 'longblob' => { data_type => 'longblob' },
117 'longtext' => { data_type => 'longtext' },
119 "enum('foo', 'bar', 'baz')"
120 => { data_type => 'enum', extra => { list => [qw/foo bar baz/] } },
121 "set('foo', 'bar', 'baz')"
122 => { data_type => 'set', extra => { list => [qw/foo bar baz/] } },
127 CREATE TABLE mysql_loader_test1 (
128 id INT AUTO_INCREMENT PRIMARY KEY,
133 CREATE VIEW mysql_loader_test2 AS SELECT * FROM mysql_loader_test1
136 pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
137 drop => [ 'mysql_loader_test1', ],
140 my ($schema, $monikers, $classes) = @_;
142 my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
144 is $rsrc->column_info('value')->{data_type}, 'varchar',
145 'view introspected successfully';
150 if( !$dsn || !$user ) {
151 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');
154 diag $skip_rels_msg if not $test_innodb;
155 $tester->run_tests();
158 # vim:et sts=4 sw=4 tw=0: