From: Peter Rabbitson Date: Thu, 9 Sep 2010 08:38:13 +0000 (+0200) Subject: And more fail fixes (this time db2) X-Git-Tag: 0.07002~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=ebed3e6e3e487ab926341b75e56cd428ae1f1419 And more fail fixes (this time db2) --- diff --git a/Changes b/Changes index 62b7e5e..93080b0 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,8 @@ Revision history for Perl extension DBIx::Class::Schema::Loader versions - Fix mssql common tests failures with MSSQL 2005 (skip test of datatypes found only on MSSQL 2008) + - Fix DB2 v8 test failures (skip tests of graphics types found + only on DB2 v9) - Fix dangerous invocation of ->meta on classes during upgrade (may be *non* moosified and contain a user-defined meta() ) diff --git a/t/13db2_common.t b/t/13db2_common.t index 4823d7e..e5d5a0e 100644 --- a/t/13db2_common.t +++ b/t/13db2_common.t @@ -1,11 +1,32 @@ 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', @@ -31,8 +52,8 @@ my $tester = dbixcsl_common_tests->new( '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] }, + '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 }, @@ -42,11 +63,7 @@ my $tester = dbixcsl_common_tests->new( 'clob' => { data_type => 'clob' }, # Graphic String Types (double-byte strings) - 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' }, + ($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' } }, @@ -78,10 +95,6 @@ my $tester = dbixcsl_common_tests->new( }, ); -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: diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 2a48570..e19c3d8 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -1841,7 +1841,7 @@ sub setup_data_type_tests { my @size = split /,/, $size; # some DBs don't like very long column names - if ($self->{vendor} =~ /^(?:firebird|sqlanywhere|oracle)\z/i) { + if ($self->{vendor} =~ /^(?:firebird|sqlanywhere|oracle|db2)\z/i) { my ($col_def, $default) = $type_alias =~ /^(.*)(default.*)?\z/i; $type_alias = substr $col_def, 0, 15;