some work on Informix data_types, datetimes and intervals left to do
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 19informix_common.t
CommitLineData
bc5afe55 1use strict;
2use lib qw(t/lib);
3use dbixcsl_common_tests;
4
b511f36e 5# to support " quoted identifiers
6BEGIN { $ENV{DELIMIDENT} = 'y' }
7
bc5afe55 8# This test doesn't run over a shared memory connection, because of the single connection limit.
9
10my $dsn = $ENV{DBICTEST_INFORMIX_DSN} || '';
11my $user = $ENV{DBICTEST_INFORMIX_USER} || '';
12my $password = $ENV{DBICTEST_INFORMIX_PASS} || '';
13
14my $tester = dbixcsl_common_tests->new(
15 vendor => 'Informix',
c7e6dc1f 16 auto_inc_pk => 'serial primary key',
bc5afe55 17 null => '',
c7e6dc1f 18 default_function => 'current year to fraction(5)',
19 default_function_def => 'datetime year to fraction(5) default current year to fraction(5)',
bc5afe55 20 dsn => $dsn,
21 user => $user,
22 password => $password,
b511f36e 23 loader_options => { preserve_case => 1 },
24 quote_char => '"',
c7e6dc1f 25 data_types => {
26 # http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp?topic=/com.ibm.sqlr.doc/ids_sqr_094.htm
27
28 # Numeric Types
29 'int' => { data_type => 'integer' },
30 integer => { data_type => 'integer' },
31 int8 => { data_type => 'bigint' },
32 bigint => { data_type => 'bigint' },
33 serial => { data_type => 'integer', is_auto_increment => 1 },
34 bigserial => { data_type => 'bigint', is_auto_increment => 1 },
35 serial8 => { data_type => 'bigint', is_auto_increment => 1 },
36 smallint => { data_type => 'smallint' },
37 real => { data_type => 'real' },
38 smallfloat => { data_type => 'real' },
39 # just 'double' is a syntax error
40 'double precision' => { data_type => 'double precision' },
41 float => { data_type => 'double precision' },
42 'float(1)' => { data_type => 'double precision' },
43 'float(5)' => { data_type => 'double precision' },
44 'float(10)' => { data_type => 'double precision' },
45 'float(15)' => { data_type => 'double precision' },
46 'float(16)' => { data_type => 'double precision' },
47 numeric => { data_type => 'numeric' },
48 decimal => { data_type => 'numeric' },
49 dec => { data_type => 'numeric' },
50 'numeric(6,3)' => { data_type => 'numeric', size => [6,3] },
51 'decimal(6,3)' => { data_type => 'numeric', size => [6,3] },
52 'dec(6,3)' => { data_type => 'numeric', size => [6,3] },
53
54 # Boolean Type
55 # XXX this should map to 'boolean'
56 boolean => { data_type => 'smallint' },
57
58 # Money Type
59 money => { data_type => 'money' },
60 'money(3,3)' => { data_type => 'numeric', size => [3,3] },
61
62 # Byte Type
63 byte => { data_type => 'bytea', original => { data_type => 'byte' } },
64
65 # Character String Types
66 char => { data_type => 'char', size => 1 },
67 'char(3)' => { data_type => 'char', size => 3 },
68 character => { data_type => 'char', size => 1 },
69 'character(3)' => { data_type => 'char', size => 3 },
70 'varchar(3)' => { data_type => 'varchar', size => 3 },
71 'character varying(3)'
72 => { data_type => 'varchar', size => 3 },
73 # XXX min size not supported, colmin from syscolumns is NULL
74 'varchar(3,2)' => { data_type => 'varchar', size => 3 },
75 'character varying(3,2)'
76 => { data_type => 'varchar', size => 3 },
77 nchar => { data_type => 'nchar', size => 1 },
78 'nchar(3)' => { data_type => 'nchar', size => 3 },
79 'nvarchar(3)' => { data_type => 'nvarchar', size => 3 },
80 'nvarchar(3,2)' => { data_type => 'nvarchar', size => 3 },
81 'lvarchar(3)' => { data_type => 'lvarchar', size => 3 },
82 'lvarchar(33)' => { data_type => 'lvarchar', size => 33 },
83 text => { data_type => 'text' },
84
85 # DateTime Types
86 date => { data_type => 'date' },
87 'date default today'
88 => { data_type => 'date', default_value => \'today' },
89 # XXX support all precisions
90 'datetime year to fraction(5)',
91 => { data_type => 'datetime year to fraction(5)' },
92 'datetime year to fraction(5) default current year to fraction(5)',
93 => { data_type => 'datetime year to fraction(5)', default_value => \'current year to fraction(5)' },
94 # XXX do interval
95
96 # Blob Types
97 # XXX no way to distinguish opaque types boolean, blob and clob
98 blob => { data_type => 'blob' },
99 clob => { data_type => 'blob' },
100
101 # IDSSECURITYLABEL Type
102 #
103 # This requires the DBSECADM privilege and a security policy on the
104 # table, things I know nothing about.
105# idssecuritylabel => { data_type => 'idssecuritylabel' },
106
107 # List Types
108 # XXX need to introspect element type too
109 'list(varchar(20) not null)'
110 => { data_type => 'list' },
111 'multiset(varchar(20) not null)'
112 => { data_type => 'multiset' },
113 'set(varchar(20) not null)'
114 => { data_type => 'set' },
115 },
bc5afe55 116);
117
118if( !$dsn ) {
119 $tester->skip_tests('You need to set the DBICTEST_INFORMIX_DSN, _USER, and _PASS environment variables');
120}
121else {
122 $tester->run_tests();
123}
124# vim:et sts=4 sw=4 tw=0: