better type info for DB2
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 13db2_common.t
1 use strict;
2 use lib qw(t/lib);
3 use dbixcsl_common_tests;
4
5 my $dsn      = $ENV{DBICTEST_DB2_DSN} || '';
6 my $user     = $ENV{DBICTEST_DB2_USER} || '';
7 my $password = $ENV{DBICTEST_DB2_PASS} || '';
8
9 my $tester = dbixcsl_common_tests->new(
10     vendor         => 'DB2',
11     auto_inc_pk    => 'INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY',
12     dsn            => $dsn,
13     user           => $user,
14     password       => $password,
15     null           => '',
16     preserve_case_mode_is_exclusive => 1,
17     quote_char                      => '"',
18     data_types => {
19         # http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0008483.htm
20         #
21         # Numeric Types
22         smallint           => { data_type => 'smallint' },
23         integer            => { data_type => 'integer' },
24         'int'              => { data_type => 'integer' },
25         real               => { data_type => 'real' },
26         'double precision' => { data_type => 'double precision' },
27         double             => { data_type => 'double precision' },
28         float              => { data_type => 'double precision' },
29         'float(24)'        => { data_type => 'real' },
30         'float(25)'        => { data_type => 'double precision' },
31         'float(53)'        => { data_type => 'double precision' },
32         numeric            => { data_type => 'numeric' },
33         decimal            => { data_type => 'numeric' },
34         'numeric(6,3)'     => { data_type => 'numeric', size => [6,3] },
35         'decimal(6,3)'     => { data_type => 'numeric', size => [6,3] },
36
37         # Character String Types
38         char               => { data_type => 'char', size => 1 },
39         'char(3)'          => { data_type => 'char', size => 3 },
40         'varchar(3)'       => { data_type => 'varchar', size => 3 },
41         'long varchar'     => { data_type => 'long varchar' },
42         'clob'             => { data_type => 'clob' },
43
44         # Graphic String Types (double-byte strings)
45         graphic            => { data_type => 'graphic', size => 1 },
46         'graphic(3)'       => { data_type => 'graphic', size => 3 },
47         'vargraphic(3)'    => { data_type => 'vargraphic', size => 3 },
48         'long vargraphic'  => { data_type => 'long vargraphic' },
49         'dbclob'           => { data_type => 'dbclob' },
50
51         # Binary String Types
52         'char for bit data'=> { data_type => 'binary', size => 1, original => { data_type => 'char for bit data' } },
53         'char(3) for bit data'
54                            => { data_type => 'binary', size => 3, original => { data_type => 'char for bit data' } },
55         'varchar(3) for bit data'
56                            => { data_type => 'varbinary', size => 3, original => { data_type => 'varchar for bit data' } },
57         'long varchar for bit data'
58                            => { data_type => 'blob', original => { data_type => 'long varchar for bit data' } },
59         blob               => { data_type => 'blob' },
60
61         # DateTime Types
62         'date'             => { data_type => 'date' },
63         'date default current date'
64                            => { data_type => 'date', default_value => \'current_timestamp',
65                                 original => { default_value => \'current date' } },
66         'time'             => { data_type => 'time' },
67         'time default current time'
68                            => { data_type => 'time', default_value => \'current_timestamp',
69                                 original => { default_value => \'current time' } },
70         timestamp          => { data_type => 'timestamp' },
71         'timestamp default current timestamp'
72                            => { data_type => 'timestamp', default_value => \'current_timestamp',
73                                 original => { default_value => \'current timestamp' } },
74
75         # DATALINK Type
76         # XXX I don't know how to make these
77 #        datalink           => { data_type => 'datalink' },
78     },
79 );
80
81 if( !$dsn || !$user ) {
82     $tester->skip_tests('You need to set the DBICTEST_DB2_DSN, _USER, and _PASS environment variables');
83 }
84 else {
85     $tester->run_tests();
86 }
87 # vim:et sts=4 sw=4 tw=0: