From: Rafael Kitover Date: Fri, 10 Jul 2009 20:53:09 +0000 (+0000) Subject: make tests pass X-Git-Tag: 0.04999_08~2^2~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0906d55b2c9770d1b52a8e17ef2a5e30f32f523c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git make tests pass --- diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 8db6032..18b9ed4 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -688,16 +688,19 @@ sub _setup_src_meta { $self->_dbic_stmt($table_class,'add_columns',@$cols); } else { - for my $col (keys %$col_info) { - $col_info->{$col}{accessor} = lc $col - if $col ne lc($col); + if ($self->_is_case_sensitive) { + for my $col (keys %$col_info) { + $col_info->{$col}{accessor} = lc $col + if $col ne lc($col); + } + } else { + $col_info = { map { lc($_), $col_info->{$_} } keys %$col_info }; } my $fks = $self->_table_fk_info($table); for my $fkdef (@$fks) { for my $col (@{ $fkdef->{local_columns} }) { - $col = lc $col unless $self->_is_case_sensitive; $col_info->{$col}{is_foreign_key} = 1; } } diff --git a/t/13db2_common.t b/t/13db2_common.t index a4dd554..b27ef4f 100644 --- a/t/13db2_common.t +++ b/t/13db2_common.t @@ -12,6 +12,7 @@ my $tester = dbixcsl_common_tests->new( dsn => $dsn, user => $user, password => $password, + null => '', ); if( !$dsn || !$user ) { diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index a2e4996..00ced93 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -27,6 +27,9 @@ sub new { # Only MySQL uses this $self->{innodb} ||= ''; + + # DB2 doesn't support this + $self->{null} = 'NULL' unless defined $self->{null}; $self->{verbose} = $ENV{TEST_VERBOSE} || 0; @@ -391,7 +394,11 @@ sub test_schema { isa_ok( $rs_rel4->first, $class4); # find on multi-col pk - my $obj5 = $rsobj5->find({id1 => 1, iD2 => 1}); + my $obj5 = + eval { $rsobj5->find({id1 => 1, iD2 => 1}) } || + eval { $rsobj5->find({id1 => 1, id2 => 1}) }; + die $@ if $@; + is( $obj5->id2, 1, "Find on multi-col PK" ); # mulit-col fk def @@ -956,7 +963,7 @@ sub create { CREATE TABLE loader_test32 ( id INTEGER NOT NULL PRIMARY KEY, rel1 INTEGER NOT NULL, - rel2 INTEGER NULL, + rel2 INTEGER $self->{null}, FOREIGN KEY (rel1) REFERENCES loader_test31(id), FOREIGN KEY (rel2) REFERENCES loader_test31(id) ) $self->{innodb} @@ -976,7 +983,7 @@ sub create { CREATE TABLE loader_test34 ( id INTEGER NOT NULL PRIMARY KEY, rel1 INTEGER NOT NULL, - rel2 INTEGER NULL, + rel2 INTEGER $self->{null}, FOREIGN KEY (id,rel1) REFERENCES loader_test33(id1,id2), FOREIGN KEY (id,rel2) REFERENCES loader_test33(id1,id2) ) $self->{innodb} @@ -989,7 +996,7 @@ sub create { CREATE TABLE loader_test10 ( id10 $self->{auto_inc_pk}, subject VARCHAR(8), - loader_test11 INTEGER NULL + loader_test11 INTEGER $self->{null} ) $self->{innodb} }, $make_auto_inc->(qw/loader_test10 id10/), @@ -998,7 +1005,7 @@ sub create { CREATE TABLE loader_test11 ( id11 $self->{auto_inc_pk}, message VARCHAR(8) DEFAULT 'foo', - loader_test10 INTEGER NULL, + loader_test10 INTEGER $self->{null}, FOREIGN KEY (loader_test10) REFERENCES loader_test10 (id10) ) $self->{innodb} },