remove is_deferrable => 1 from default for belongs_to rels
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 11mysql_common.t
CommitLineData
a78e3fed 1use strict;
26334ec1 2use Test::More;
c2849787 3use lib qw(t/lib);
fbd83464 4use dbixcsl_common_tests;
a78e3fed 5
9e978a19 6my $dsn = $ENV{DBICTEST_MYSQL_DSN} || '';
7my $user = $ENV{DBICTEST_MYSQL_USER} || '';
8my $password = $ENV{DBICTEST_MYSQL_PASS} || '';
9my $test_innodb = $ENV{DBICTEST_MYSQL_INNODB} || 0;
a78e3fed 10
26334ec1 11my $skip_rels_msg = 'You need to set the DBICTEST_MYSQL_INNODB environment variable to test relationships.';
a78e3fed 12
fbd83464 13my $tester = dbixcsl_common_tests->new(
52bf3f26 14 vendor => 'Mysql',
15 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT',
16 innodb => $test_innodb ? q{Engine=InnoDB} : 0,
17 dsn => $dsn,
18 user => $user,
19 password => $password,
309e2aa1 20 connect_info_opts=> { on_connect_call => 'set_strict_mode' },
eb040f78 21 loader_options => { preserve_case => 1 },
8ff3a23a 22 skip_rels => $test_innodb ? 0 : $skip_rels_msg,
52bf3f26 23 no_inline_rels => 1,
24 no_implicit_rels => 1,
98857177 25 data_types => {
26 # http://dev.mysql.com/doc/refman/5.5/en/data-type-overview.html
27 # Numeric Types
26334ec1 28 'bit' => { data_type => 'bit', size => 1 },
29 'bit(11)' => { data_type => 'bit', size => 11 },
30
31 'bool' => { data_type => 'tinyint' },
32 'boolean' => { data_type => 'tinyint' },
33 'tinyint' => { data_type => 'tinyint' },
34 'tinyint unsigned'
35 => { data_type => 'tinyint', extra => { unsigned => 1 } },
36 'smallint' => { data_type => 'smallint' },
37 'smallint unsigned'
38 => { data_type => 'smallint', extra => { unsigned => 1 } },
39 'mediumint' => { data_type => 'mediumint' },
40 'mediumint unsigned'
41 => { data_type => 'mediumint', extra => { unsigned => 1 } },
42 'int' => { data_type => 'integer' },
43 'int unsigned'
44 => { data_type => 'integer', extra => { unsigned => 1 } },
45 'integer' => { data_type => 'integer' },
46 'integer unsigned'
47 => { data_type => 'integer', extra => { unsigned => 1 } },
48 'bigint' => { data_type => 'bigint' },
49 'bigint unsigned'
50 => { data_type => 'bigint', extra => { unsigned => 1 } },
51
52 'serial' => { data_type => 'bigint', is_auto_increment => 1, extra => { unsigned => 1 } },
53
54 'float' => { data_type => 'float' },
55 'float unsigned'
56 => { data_type => 'float', extra => { unsigned => 1 } },
57 'double' => { data_type => 'double precision' },
58 'double unsigned'
59 => { data_type => 'double precision', extra => { unsigned => 1 } },
98857177 60 'double precision' =>
26334ec1 61 { data_type => 'double precision' },
62 'double precision unsigned'
63 => { data_type => 'double precision', extra => { unsigned => 1 } },
64
65 # we skip 'real' because its alias depends on the 'REAL AS FLOAT' setting
66
67 'float(2)' => { data_type => 'float' },
68 'float(24)' => { data_type => 'float' },
69 'float(25)' => { data_type => 'double precision' },
70
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] },
75
76 'decimal' => { data_type => 'decimal' },
77 'decimal unsigned'
78 => { data_type => 'decimal', extra => { unsigned => 1 } },
79 'dec' => { data_type => 'decimal' },
80 'numeric' => { data_type => 'decimal' },
81 'fixed' => { data_type => 'decimal' },
82
83 'decimal(3)' => { data_type => 'decimal', size => [3,0] },
84
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] },
89
98857177 90 # Date and Time Types
26334ec1 91 'date' => { data_type => 'date' },
92 'datetime' => { data_type => 'datetime' },
6e566cc4 93 'timestamp default current_timestamp'
94 => { data_type => 'timestamp', default_value => \'current_timestamp' },
26334ec1 95 'time' => { data_type => 'time' },
96 'year' => { data_type => 'year' },
97 'year(4)' => { data_type => 'year' },
98 'year(2)' => { data_type => 'year', size => 2 },
99
98857177 100 # String Types
26334ec1 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 },
107
108 'tinyblob' => { data_type => 'tinyblob' },
109 'tinytext' => { data_type => 'tinytext' },
110 'blob' => { data_type => 'blob' },
111
112 # text(M) types will map to the appropriate type, length is not stored
113 'text' => { data_type => 'text' },
114
115 'mediumblob' => { data_type => 'mediumblob' },
116 'mediumtext' => { data_type => 'mediumtext' },
117 'longblob' => { data_type => 'longblob' },
118 'longtext' => { data_type => 'longtext' },
119
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/] } },
98857177 124 },
3de915bc 125 extra => {
126 create => [
127 q{
128 CREATE TABLE mysql_loader_test1 (
129 id INT AUTO_INCREMENT PRIMARY KEY,
130 value varchar(100)
131 )
132 },
133 q{
134 CREATE VIEW mysql_loader_test2 AS SELECT * FROM mysql_loader_test1
135 },
136 ],
137 pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ],
138 drop => [ 'mysql_loader_test1', ],
139 count => 1,
140 run => sub {
141 my ($schema, $monikers, $classes) = @_;
142
143 my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source;
144
145 is $rsrc->column_info('value')->{data_type}, 'varchar',
146 'view introspected successfully';
147 },
148 },
a78e3fed 149);
150
9e978a19 151if( !$dsn || !$user ) {
152 $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, _USER, and _PASS environment variables');
a78e3fed 153}
154else {
26334ec1 155 diag $skip_rels_msg if not $test_innodb;
a78e3fed 156 $tester->run_tests();
157}
26334ec1 158
159# vim:et sts=4 sw=4 tw=0: