Schema::Loader converted to better inheritance model, no longer pollutes user schema...
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / Pg.pm
index 04e67f1..0d49c95 100644 (file)
@@ -1,8 +1,8 @@
 package DBIx::Class::Schema::Loader::Pg;
 
 use strict;
+use warnings;
 use base 'DBIx::Class::Schema::Loader::Generic';
-use Carp;
 
 =head1 NAME
 
@@ -17,7 +17,6 @@ DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implement
     dsn       => "dbi:Pg:dbname=dbname",
     user      => "postgres",
     password  => "",
-    namespace => "Data",
   );
 
 =head1 DESCRIPTION
@@ -31,30 +30,33 @@ sub _db_classes {
 }
 
 sub _tables {
-    my $class = shift;
-    my $dbh = $class->storage->dbh;
+    my $self = shift;
+    my $dbh = $self->schema->storage->dbh;
+    my $quoter = $dbh->get_info(29) || q{"};
 
     # 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, $class->loader_data->{_db_schema}, "", "table", { noprefix => 1, pg_noprefix => 1 } )
+    my @tables = $is_dbd_pg_gte_131
+        ?  $dbh->tables( undef, $self->db_schema, "",
+                         "table", { noprefix => 1, pg_noprefix => 1 } )
         : $dbh->tables;
 
-    s/"//g for @tables;
+    s/$quoter//g for @tables;
     return @tables;
 }
 
 sub _table_info {
-    my ( $class, $table ) = @_;
-    my $dbh = $class->storage->dbh;
+    my ( $self, $table ) = @_;
+    my $dbh = $self->schema->storage->dbh;
+    my $quoter = $dbh->get_info(29) || q{"};
 
-    my $sth = $dbh->column_info(undef, $class->loader_data->{_db_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;
+    s/$quoter//g for @cols;
     
-    my @primary = $dbh->primary_key(undef, $class->loader_data->{_db_schema}, $table);
+    my @primary = $dbh->primary_key(undef, $self->db_schema, $table);
 
-    s/"//g for @primary;
+    s/$quoter//g for @primary;
 
     return ( \@cols, \@primary );
 }