use strict;
use warnings;
use base 'DBIx::Class::Schema::Loader::DBI';
+use Carp::Clan qw/^DBIx::Class/;
use Class::C3;
+our $VERSION = '0.04006';
+
=head1 NAME
DBIx::Class::Schema::Loader::DBI::DB2 - DBIx::Class::Schema::Loader::DBI DB2 Implementation.
package My::Schema;
use base qw/DBIx::Class::Schema::Loader/;
- __PACKAGE__->loader_options(
- relationships => 1,
- db_schema => "MYSCHEMA",
- );
+ __PACKAGE__->loader_options( db_schema => "MYSCHEMA" );
1;
my $dbh = $self->schema->storage->dbh;
- my $sth = $dbh->prepare(<<'SQL') or die;
-SELECT kcu.COLNAME, kcu.CONSTNAME, kcu.COLSEQ
-FROM SYSCAT.TABCONST as tc
-JOIN SYSCAT.KEYCOLUSE as kcu ON tc.CONSTNAME = kcu.CONSTNAME
-WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'
-SQL
+ 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
+ WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'}
+ ) or die $DBI::errstr;
- $sth->execute($self->db_schema, $table) or die;
+ $sth->execute($self->db_schema, uc $table) or die $DBI::errstr;
my %keydata;
while(my $row = $sth->fetchrow_arrayref) {
@{$keydata{$keyname}};
push(@uniqs, [ $keyname => \@ordered_cols ]);
}
+
$sth->finish;
return \@uniqs;
}
+sub _tables_list {
+ my $self = shift;
+ return map lc, $self->next::method;
+}
+
+sub _table_pk_info {
+ my ($self, $table) = @_;
+ return $self->next::method(uc $table);
+}
+
+sub _table_fk_info {
+ my ($self, $table) = @_;
+
+ my $rels = $self->next::method(uc $table);
+
+ foreach my $rel (@$rels) {
+ $rel->{remote_table} = lc $rel->{remote_table};
+ }
+
+ return $rels;
+}
+
+sub _columns_info_for {
+ my ($self, $table) = @_;
+ return $self->next::method(uc $table);
+}
+
=head1 SEE ALSO
L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,