1 package DBIx::Class::Storage::DBI::Pg;
6 use base qw/DBIx::Class::Storage::DBI/;
8 # __PACKAGE__->load_components(qw/PK::Auto/);
10 # Warn about problematic versions of DBD::Pg
11 warn "DBD::Pg 1.49 is strongly recommended"
12 if ($DBD::Pg::VERSION < 1.49);
15 my ($self,$source,$col) = @_;
16 my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
17 $self->_dbh->last_insert_id(undef,undef,undef,undef, {sequence => $seq});
21 my ($self,$source,$col) = @_;
23 my @pri = $source->primary_columns;
24 my $dbh = $self->_dbh;
25 my ($schema,$table) = $source->name =~ /^(.+)\.(.+)$/ ? ($1,$2)
26 : (undef,$source->name);
27 while (my $col = shift @pri) {
28 my $info = $dbh->column_info(undef,$schema,$table,$col)->fetchrow_hashref;
29 if (defined $info->{COLUMN_DEF} and $info->{COLUMN_DEF} =~
30 /^nextval\(+'([^']+)'::(?:text|regclass)\)/)
33 return $seq =~ /\./ ? $seq : $info->{TABLE_SCHEM} . "." . $seq; # may need to strip quotes -- see if this works
42 sub datetime_parser_type { return "DateTime::Format::Pg"; }
48 DBIx::Class::Storage::DBI::Pg - Automatic primary key class for PostgreSQL
52 # In your table classes
53 __PACKAGE__->load_components(qw/PK::Auto Core/);
54 __PACKAGE__->set_primary_key('id');
55 __PACKAGE__->sequence('mysequence');
59 This class implements autoincrements for PostgreSQL.
63 Marcus Ramberg <m.ramberg@cpan.org>
67 You may distribute this code under the same terms as Perl itself.