1 package DBIx::Class::Schema::Loader::Pg;
7 use base 'DBIx::Class::Schema::Loader::Generic';
11 DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implementation.
15 use DBIx::Class::Schema::Loader;
17 # $loader is a DBIx::Class::Schema::Loader::Pg
18 my $loader = DBIx::Class::Schema::Loader->new(
19 dsn => "dbi:Pg:dbname=dbname",
26 See L<DBIx::Class::Schema::Loader>.
32 Overrides L<DBIx::Class::Schema::Loader::Generic>'s C<new()> to default the postgres
33 schema to C<public> rather than blank.
38 my ($class, %args) = @_;
40 my $self = $class->next::method(%args);
41 $self->{db_schema} ||= 'public';
47 return qw/DBIx::Class::PK::Auto::Pg/;
52 my $dbh = $self->schema->storage->dbh;
53 my $quoter = $dbh->get_info(29) || q{"};
55 # This is split out to avoid version parsing errors...
56 my $is_dbd_pg_gte_131 = ( $DBD::Pg::VERSION >= 1.31 );
57 my @tables = $is_dbd_pg_gte_131
58 ? $dbh->tables( undef, $self->db_schema, "",
59 "table", { noprefix => 1, pg_noprefix => 1 } )
62 s/$quoter//g for @tables;
67 my ( $self, $table ) = @_;
68 my $dbh = $self->schema->storage->dbh;
69 my $quoter = $dbh->get_info(29) || q{"};
71 my $sth = $dbh->column_info(undef, $self->db_schema, $table, undef);
72 my @cols = map { $_->[3] } @{ $sth->fetchall_arrayref };
73 s/$quoter//g for @cols;
75 my @primary = $dbh->primary_key(undef, $self->db_schema, $table);
77 s/$quoter//g for @primary;
79 return ( \@cols, \@primary );
84 L<DBIx::Class::Schema::Loader>