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