loader as a schema subclass basically working (needs some cleanup and docs and whatnot)
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / Pg.pm
index 6bc4f80..04e67f1 100644 (file)
@@ -2,7 +2,6 @@ package DBIx::Class::Schema::Loader::Pg;
 
 use strict;
 use base 'DBIx::Class::Schema::Loader::Generic';
-use DBI;
 use Carp;
 
 =head1 NAME
@@ -32,13 +31,13 @@ sub _db_classes {
 }
 
 sub _tables {
-    my $self = shift;
-    my $dbh = $self->{_storage}->dbh;
+    my $class = shift;
+    my $dbh = $class->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, $self->{_db_schema}, "", "table", { noprefix => 1, pg_noprefix => 1 } )
+        $dbh->tables( undef, $class->loader_data->{_db_schema}, "", "table", { noprefix => 1, pg_noprefix => 1 } )
         : $dbh->tables;
 
     s/"//g for @tables;
@@ -46,14 +45,14 @@ sub _tables {
 }
 
 sub _table_info {
-    my ( $self, $table ) = @_;
-    my $dbh = $self->{_storage}->dbh;
+    my ( $class, $table ) = @_;
+    my $dbh = $class->storage->dbh;
 
-    my $sth = $dbh->column_info(undef, $self->{_db_schema}, $table, undef);
+    my $sth = $dbh->column_info(undef, $class->loader_data->{_db_schema}, $table, undef);
     my @cols = map { $_->[3] } @{ $sth->fetchall_arrayref };
     s/"//g for @cols;
     
-    my @primary = $dbh->primary_key(undef, $self->{_db_schema}, $table);
+    my @primary = $dbh->primary_key(undef, $class->loader_data->{_db_schema}, $table);
 
     s/"//g for @primary;