1 package DBIx::Class::Schema::Loader::Pg;
6 use base 'DBIx::Class::Schema::Loader::Generic';
10 DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implementation.
15 use base qw/DBIx::Class::Schema::Loader/;
17 __PACKAGE__->load_from_connection(
18 dsn => "dbi:Pg:dbname=dbname",
27 See L<DBIx::Class::Schema::Loader>.
33 Overrides L<DBIx::Class::Schema::Loader::Generic>'s C<new()> to default the postgres
34 schema to C<public> rather than blank.
39 my ($class, %args) = @_;
41 my $self = $class->next::method(%args);
42 $self->{db_schema} ||= 'public';
48 return qw/PK::Auto::Pg/;
53 my $dbh = $self->schema->storage->dbh;
54 my $quoter = $dbh->get_info(29) || q{"};
56 # This is split out to avoid version parsing errors...
57 my $is_dbd_pg_gte_131 = ( $DBD::Pg::VERSION >= 1.31 );
58 my @tables = $is_dbd_pg_gte_131
59 ? $dbh->tables( undef, $self->db_schema, "",
60 "table", { noprefix => 1, pg_noprefix => 1 } )
63 s/$quoter//g for @tables;
68 my ( $self, $table ) = @_;
69 my $dbh = $self->schema->storage->dbh;
70 my $quoter = $dbh->get_info(29) || q{"};
72 my $sth = $dbh->column_info(undef, $self->db_schema, $table, undef);
73 my @cols = map { $_->[3] } @{ $sth->fetchall_arrayref };
74 s/$quoter//g for @cols;
76 my @primary = $dbh->primary_key(undef, $self->db_schema, $table);
78 s/$quoter//g for @primary;
80 return ( \@cols, \@primary );
85 L<DBIx::Class::Schema::Loader>