X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FPg.pm;h=538c6bed6b9ed29aeb4c9175dc611e90f5bfb72d;hb=0a701ff3cc71ab221fada2b2dc8c5a42232ab4ae;hp=a2ddb280f48b03781e114d2016055984cd813ff8;hpb=8f9d7ce50bb37fdc2a823b9c79b18fb32ee5f068;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index a2ddb28..538c6be 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -3,8 +3,11 @@ package DBIx::Class::Schema::Loader::DBI::Pg; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBI'; +use Carp::Clan qw/^DBIx::Class/; use Class::C3; +our $VERSION = '0.04999_12'; + =head1 NAME DBIx::Class::Schema::Loader::DBI::Pg - DBIx::Class::Schema::Loader::DBI @@ -15,9 +18,7 @@ PostgreSQL Implementation. package My::Schema; use base qw/DBIx::Class::Schema::Loader/; - __PACKAGE__->loader_options( - relationships => 1, - ); + __PACKAGE__->loader_options( debug => 1 ); 1; @@ -34,9 +35,14 @@ sub _setup { $self->{db_schema} ||= 'public'; } + sub _table_uniq_info { my ($self, $table) = @_; + # Use the default support if available + return $self->next::method($table) + if $DBD::Pg::VERSION >= 1.50; + my @uniqs; my $dbh = $self->schema->storage->dbh; @@ -90,11 +96,57 @@ sub _table_uniq_info { return \@uniqs; } +sub _table_comment { + my ( $self, $table ) = @_; + my ($table_comment) = $self->schema->storage->dbh->selectrow_array( + q{SELECT obj_description(oid) + FROM pg_class + WHERE relname=? AND relnamespace=( + SELECT oid FROM pg_namespace WHERE nspname=?) + }, undef, $table, $self->db_schema + ); + return $table_comment +} + + +sub _column_comment { + my ( $self, $table, $column_number ) = @_; + my ($table_oid) = $self->schema->storage->dbh->selectrow_array( + q{SELECT oid + FROM pg_class + WHERE relname=? AND relnamespace=( + SELECT oid FROM pg_namespace WHERE nspname=?) + }, undef, $table, $self->db_schema + ); + return $self->schema->storage->dbh->selectrow_array('SELECT col_description(?,?)', undef, $table_oid, + $column_number ); +} + +sub _extra_column_info { + my ($self, $info) = @_; + my %extra_info; + + if ($info->{COLUMN_DEF} && $info->{COLUMN_DEF} =~ /\bnextval\(/i) { + $extra_info{is_auto_increment} = 1; + } + + return \%extra_info; +} + =head1 SEE ALSO L, L, L +=head1 AUTHOR + +See L. + +=head1 LICENSE + +This library is free software; you can redistribute it and/or modify it under +the same terms as Perl itself. + =cut 1;