X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FDB2.pm;h=87e4150f9036d7768688cea5fe79891dc3cf913a;hb=b1ad1a8402a5eb0955c6b76310809c2ab29291a9;hp=bd17516901dfdf9f3e40176355eb1deea0ed1b03;hpb=a6db40afa6a8ee294f893461dbef8bfcb0f0688c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index bd17516..87e4150 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.04005'; +our $VERSION = '0.04999_10'; =head1 NAME @@ -27,6 +27,15 @@ See L. =cut +sub _setup { + my $self = shift; + + $self->next::method(@_); + + my $dbh = $self->schema->storage->dbh; + $self->{db_schema} ||= $dbh->selectrow_array('VALUES(CURRENT_USER)', {}); +} + sub _table_uniq_info { my ($self, $table) = @_; @@ -59,9 +68,18 @@ sub _table_uniq_info { return \@uniqs; } -sub _tables_list { +# DBD::DB2 doesn't follow the DBI API for ->tables +sub _tables_list { my $self = shift; - return map lc, $self->next::method; + + my $dbh = $self->schema->storage->dbh; + my @tables = map { lc } $dbh->tables( + $self->db_schema ? { TABLE_SCHEM => $self->db_schema } : undef + ); + s/\Q$self->{_quoter}\E//g for @tables; + s/^.*\Q$self->{_namesep}\E// for @tables; + + return @tables; } sub _table_pk_info { @@ -86,6 +104,29 @@ sub _columns_info_for { return $self->next::method(uc $table); } +sub _extra_column_info { + my ($self, $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{ + SELECT COUNT(*) + FROM syscat.columns + WHERE tabschema = ? AND tabname = ? AND colname = ? + AND identity = 'Y' AND generated != '' + }, + {}, 1); + $sth->execute($self->db_schema, $table, $column); + if ($sth->fetchrow_array) { + $extra_info{is_auto_increment} = 1; + } + + return \%extra_info; +} + =head1 SEE ALSO L, L,