From: Rafael Kitover <rkitover@cpan.org>
Date: Tue, 13 Apr 2010 06:07:03 +0000 (-0400)
Subject: fix unique detection in DB2 for multiple schemas (RT#39622)
X-Git-Tag: 0.07000~69
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ae32aaf6561185f0e1f7983416547f3a6848fa06;p=dbsrgits%2FDBIx-Class-Schema-Loader.git

fix unique detection in DB2 for multiple schemas (RT#39622)
---

diff --git a/Changes b/Changes
index b52165a..f3f02a9 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - fix unique detection in DB2 for multiple schemas (RT#39622)
         - fix column name collisions with methods (RT#49443)
         - fix loading MySQL views on older MySQL versions (RT#47399)
 
diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
index a79ff14..7567d16 100644
--- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
+++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
@@ -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;