fix unique detection in DB2 for multiple schemas (RT#39622)
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / DB2.pm
index 8268adb..7567d16 100644 (file)
@@ -9,7 +9,7 @@ use base qw/
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
-our $VERSION = '0.05001';
+our $VERSION = '0.06001';
 
 =head1 NAME
 
@@ -49,7 +49,8 @@ sub _table_uniq_info {
     my $sth = $self->{_cache}->{db2_uniq} ||= $dbh->prepare(
         q{SELECT kcu.COLNAME, kcu.CONSTNAME, kcu.COLSEQ
         FROM SYSCAT.TABCONST as tc
-        JOIN SYSCAT.KEYCOLUSE as kcu ON tc.CONSTNAME = kcu.CONSTNAME
+        JOIN SYSCAT.KEYCOLUSE as kcu
+        ON tc.CONSTNAME = kcu.CONSTNAME AND tc.TABSCHEMA = kcu.TABSCHEMA
         WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'}
     ) or die $DBI::errstr;
 
@@ -73,7 +74,7 @@ sub _table_uniq_info {
 
 # DBD::DB2 doesn't follow the DBI API for ->tables
 sub _tables_list { 
-    my $self = shift;
+    my ($self, $opts) = @_;
     
     my $dbh = $self->schema->storage->dbh;
     my @tables = map { lc } $dbh->tables(
@@ -82,7 +83,7 @@ sub _tables_list {
     s/\Q$self->{_quoter}\E//g for @tables;
     s/^.*\Q$self->{_namesep}\E// for @tables;
 
-    return @tables;
+    return $self->_filter_tables(\@tables, $opts);
 }
 
 sub _table_pk_info {
@@ -108,11 +109,9 @@ sub _columns_info_for {
 }
 
 sub _extra_column_info {
-    my ($self, $info) = @_;
+    my ($self, $table, $column, $info, $dbi_info) = @_;
     my %extra_info;
 
-    my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/};
-
     my $dbh = $self->schema->storage->dbh;
     my $sth = $dbh->prepare_cached(
         q{