And more fail fixes (this time db2)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 13db2_common.t
index e616f21..e5d5a0e 100644 (file)
 use strict;
-use lib qw(t/lib);
-use dbixcsl_common_tests;
+
+use Test::More;
 
 my $dsn      = $ENV{DBICTEST_DB2_DSN} || '';
 my $user     = $ENV{DBICTEST_DB2_USER} || '';
 my $password = $ENV{DBICTEST_DB2_PASS} || '';
 
+plan skip_all => 'You need to set the DBICTEST_DB2_DSN, _USER, and _PASS environment variables'
+    unless ($dsn && $user);
+
+my $srv_ver = do {
+    require DBI;
+    my $dbh = DBI->connect ($dsn, $user, $password, { RaiseError => 1, PrintError => 0} );
+    eval { $dbh->get_info(18) } || 0;
+};
+my ($maj_srv_ver) = $srv_ver =~ /^(\d+)/;
+
+use lib qw(t/lib);
+use dbixcsl_common_tests;
+
+my $extra_graphics_data_types = {
+    graphic            => { data_type => 'graphic', size => 1 },
+    'graphic(3)'       => { data_type => 'graphic', size => 3 },
+    'vargraphic(3)'    => { data_type => 'vargraphic', size => 3 },
+    'long vargraphic'  => { data_type => 'long vargraphic' },
+    'dbclob'           => { data_type => 'dbclob' },
+};
+
 my $tester = dbixcsl_common_tests->new(
     vendor         => 'DB2',
     auto_inc_pk    => 'INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY',
     dsn            => $dsn,
     user           => $user,
     password       => $password,
-    db_schema      => uc $user,
-    no_auto_increment => 1
+    null           => '',
+    preserve_case_mode_is_exclusive => 1,
+    quote_char                      => '"',
+    data_types => {
+        # http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0008483.htm
+        #
+        # Numeric Types
+        smallint           => { data_type => 'smallint' },
+        integer            => { data_type => 'integer' },
+        'int'              => { data_type => 'integer' },
+        real               => { data_type => 'real' },
+        'double precision' => { data_type => 'double precision' },
+        double             => { data_type => 'double precision' },
+        float              => { data_type => 'double precision' },
+        'float(24)'        => { data_type => 'real' },
+        'float(25)'        => { data_type => 'double precision' },
+        'float(53)'        => { data_type => 'double precision' },
+        numeric            => { data_type => 'numeric' },
+        decimal            => { data_type => 'numeric' },
+        'numeric(6,3)'     => { data_type => 'numeric', size => [6,3] },
+        'decimal(6,3)'     => { data_type => 'numeric', size => [6,3] },
+
+        # Character String Types
+        char               => { data_type => 'char', size => 1 },
+        'char(3)'          => { data_type => 'char', size => 3 },
+        'varchar(3)'       => { data_type => 'varchar', size => 3 },
+        'long varchar'     => { data_type => 'long varchar' },
+        'clob'             => { data_type => 'clob' },
+
+        # Graphic String Types (double-byte strings)
+        ($maj_srv_ver >= 9) ? (%$extra_graphics_data_types) : (),
+
+        # Binary String Types
+        'char for bit data'=> { data_type => 'binary', size => 1, original => { data_type => 'char for bit data' } },
+        'char(3) for bit data'
+                           => { data_type => 'binary', size => 3, original => { data_type => 'char for bit data' } },
+        'varchar(3) for bit data'
+                           => { data_type => 'varbinary', size => 3, original => { data_type => 'varchar for bit data' } },
+        'long varchar for bit data'
+                           => { data_type => 'blob', original => { data_type => 'long varchar for bit data' } },
+        blob               => { data_type => 'blob' },
+
+        # DateTime Types
+        'date'             => { data_type => 'date' },
+        'date default current date'
+                           => { data_type => 'date', default_value => \'current_timestamp',
+                                original => { default_value => \'current date' } },
+        'time'             => { data_type => 'time' },
+        'time default current time'
+                           => { data_type => 'time', default_value => \'current_timestamp',
+                                original => { default_value => \'current time' } },
+        timestamp          => { data_type => 'timestamp' },
+        'timestamp default current timestamp'
+                           => { data_type => 'timestamp', default_value => \'current_timestamp',
+                                original => { default_value => \'current timestamp' } },
+
+        # DATALINK Type
+        # XXX I don't know how to make these
+#        datalink           => { data_type => 'datalink' },
+    },
 );
 
-if( !$dsn || !$user ) {
-    $tester->skip_tests('You need to set the DBICTEST_DB2_DSN, _USER, and _PASS environment variables');
-}
-else {
-    $tester->run_tests();
-}
+$tester->run_tests();
+
+# vim:et sts=4 sw=4 tw=0: