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 } },
48 'bigint' => { data_type => 'bigint' },
50 => { data_type => 'bigint', extra => { unsigned => 1 } },
52 'serial' => { data_type => 'bigint', is_auto_increment => 1, extra => { unsigned => 1 } },
54 'float' => { data_type => 'float' },
56 => { data_type => 'float', extra => { unsigned => 1 } },
57 'double' => { data_type => 'double precision' },
59 => { data_type => 'double precision', extra => { unsigned => 1 } },
61 { data_type => 'double precision' },
62 'double precision unsigned'
63 => { data_type => 'double precision', extra => { unsigned => 1 } },
65 # we skip 'real' because its alias depends on the 'REAL AS FLOAT' setting
67 'float(2)' => { data_type => 'float' },
68 'float(24)' => { data_type => 'float' },
69 'float(25)' => { data_type => 'double precision' },
71 'float(3,3)' => { data_type => 'float', size => [3,3] },
72 'double(3,3)' => { data_type => 'double precision', size => [3,3] },
73 'double precision(3,3)'
74 => { data_type => 'double precision', size => [3,3] },
76 'decimal' => { data_type => 'decimal' },
78 => { data_type => 'decimal', extra => { unsigned => 1 } },
79 'dec' => { data_type => 'decimal' },
80 'numeric' => { data_type => 'decimal' },
81 'fixed' => { data_type => 'decimal' },
83 'decimal(3)' => { data_type => 'decimal', size => [3,0] },
85 'decimal(3,3)' => { data_type => 'decimal', size => [3,3] },
86 'dec(3,3)' => { data_type => 'decimal', size => [3,3] },
87 'numeric(3,3)' => { data_type => 'decimal', size => [3,3] },
88 'fixed(3,3)' => { data_type => 'decimal', size => [3,3] },
91 'date' => { data_type => 'date' },
92 'datetime' => { data_type => 'datetime' },
93 'timestamp DEFAULT current_timestamp'
94 => { data_type => 'timestamp', default_value => \"CURRENT_TIMESTAMP" },
95 'time' => { data_type => 'time' },
96 'year' => { data_type => 'year' },
97 'year(4)' => { data_type => 'year' },
98 'year(2)' => { data_type => 'year', size => 2 },
101 'char' => { data_type => 'char', size => 1 },
102 'char(11)' => { data_type => 'char', size => 11 },
103 'varchar(20)' => { data_type => 'varchar', size => 20 },
104 'binary' => { data_type => 'binary', size => 1 },
105 'binary(11)' => { data_type => 'binary', size => 11 },
106 'varbinary(20)'=> { data_type => 'varbinary', size => 20 },
108 'tinyblob' => { data_type => 'tinyblob' },
109 'tinytext' => { data_type => 'tinytext' },
110 'blob' => { data_type => 'blob' },
112 # text(M) types will map to the appropriate type, length is not stored
113 'text' => { data_type => 'text' },
115 'mediumblob' => { data_type => 'mediumblob' },
116 'mediumtext' => { data_type => 'mediumtext' },
117 'longblob' => { data_type => 'longblob' },
118 'longtext' => { data_type => 'longtext' },
120 "enum('foo', 'bar', 'baz')"
121 => { data_type => 'enum', extra => { list => [qw/foo bar baz/] } },
122 "set('foo', 'bar', 'baz')"
123 => { data_type => 'set', extra => { list => [qw/foo bar baz/] } },
128 CREATE TABLE mysql_loader_test1 (
129 id INT AUTO_INCREMENT PRIMARY KEY,
134 CREATE VIEW mysql_loader_test2 AS SELECT * FROM mysql_loader_test1
137 pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
138 drop => [ 'mysql_loader_test1', ],
141 my ($schema, $monikers, $classes) = @_;
143 my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
145 is $rsrc->column_info('value')->{data_type}, 'varchar',
146 'view introspected successfully';
151 if( !$dsn || !$user ) {
152 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');
155 diag $skip_rels_msg if not $test_innodb;
156 $tester->run_tests();
159 # vim:et sts=4 sw=4 tw=0: