And more fail fixes (this time db2)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 13db2_common.t
CommitLineData
a78e3fed 1use strict;
ebed3e6e 2
3use Test::More;
a78e3fed 4
9e978a19 5my $dsn = $ENV{DBICTEST_DB2_DSN} || '';
6my $user = $ENV{DBICTEST_DB2_USER} || '';
7my $password = $ENV{DBICTEST_DB2_PASS} || '';
a78e3fed 8
ebed3e6e 9plan skip_all => 'You need to set the DBICTEST_DB2_DSN, _USER, and _PASS environment variables'
10 unless ($dsn && $user);
11
12my $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};
17my ($maj_srv_ver) = $srv_ver =~ /^(\d+)/;
18
19use lib qw(t/lib);
20use dbixcsl_common_tests;
21
22my $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
fbd83464 30my $tester = dbixcsl_common_tests->new(
af96f52e 31 vendor => 'DB2',
32 auto_inc_pk => 'INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY',
9e978a19 33 dsn => $dsn,
af96f52e 34 user => $user,
35 password => $password,
0906d55b 36 null => '',
b511f36e 37 preserve_case_mode_is_exclusive => 1,
38 quote_char => '"',
8a64178e 39 data_types => {
7640ef4b 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' },
ebed3e6e 55 'numeric(6,3)' => { data_type => 'numeric', size => [6,3] },
56 'decimal(6,3)' => { data_type => 'numeric', size => [6,3] },
7640ef4b 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)
ebed3e6e 66 ($maj_srv_ver >= 9) ? (%$extra_graphics_data_types) : (),
7640ef4b 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' },
8a64178e 95 },
a78e3fed 96);
97
ebed3e6e 98$tester->run_tests();
99
8a64178e 100# vim:et sts=4 sw=4 tw=0: