use DBI;
use Carp;
-our $SCHEMA = 'public';
-
=head1 NAME
DBIx::Class::Loader::Pg - DBIx::Class::Loader Postgres Implementation.
sub _tables {
my $self = shift;
- my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr);
+ my $dbh = $self->{_storage}->dbh;
# This is split out to avoid version parsing errors...
my $is_dbd_pg_gte_131 = ( $DBD::Pg::VERSION >= 1.31 );
my @tables = $is_dbd_pg_gte_131 ?
- $dbh->tables( undef, $SCHEMA, "", "table", { noprefix => 1, pg_noprefix => 1 } )
+ $dbh->tables( undef, $self->{_db_schema}, "", "table", { noprefix => 1, pg_noprefix => 1 } )
: $dbh->tables;
- $dbh->disconnect;
s/"//g for @tables;
return @tables;
}
sub _table_info {
my ( $self, $table ) = @_;
- my $dbh = DBI->connect( @{ $self->{_datasource} } ) or croak($DBI::errstr);
+ my $dbh = $self->{_storage}->dbh;
- my $sth = $dbh->column_info(undef, $SCHEMA, $table, undef);
+ my $sth = $dbh->column_info(undef, $self->{_db_schema}, $table, undef);
my @cols = map { $_->[3] } @{ $sth->fetchall_arrayref };
s/"//g for @cols;
- my @primary = $dbh->primary_key(undef, $SCHEMA, $table);
-
- $dbh->disconnect;
+ my @primary = $dbh->primary_key(undef, $self->{_db_schema}, $table);
s/"//g for @primary;