1 package DBIx::Class::Storage::DBI::Pg;
6 use base qw/DBIx::Class::Storage::DBI/;
8 # __PACKAGE__->load_components(qw/PK::Auto/);
11 my ($self, $source) = @_;
12 $self->get_autoinc_seq unless $self->{_autoinc_seq};
13 $self->_dbh->last_insert_id(undef,undef,undef,undef,
14 {sequence=>$self->{_autoinc_seq}});
20 # return the user-defined sequence if known
21 if ($source->sequence) {
22 return $self->{_autoinc_seq} = $source->sequence;
25 my @pri = $source->primary_columns;
26 my $dbh = $self->_dbh;
27 my ($schema,$table) = $source->name =~ /^(.+)\.(.+)$/ ? ($1,$2) : (undef,$sou
29 while (my $col = shift @pri) {
30 my $info = $dbh->column_info(undef,$schema,$table,$col)->fetchrow_arrayref;
31 if (defined $info->[12] and $info->[12] =~
32 /^nextval\('"?([^"']+)"?'::(?:text|regclass)\)/)
34 $self->{_autoinc_seq} = $1;
44 DBIx::Class::Storage::DBI::Pg - Automatic primary key class for PostgreSQL
48 # In your table classes
49 __PACKAGE__->load_components(qw/PK::Auto Core/);
50 __PACKAGE__->set_primary_key('id');
51 __PACKAGE__->sequence('mysequence');
55 This class implements autoincrements for PostgreSQL.
59 Marcus Ramberg <m.ramberg@cpan.org>
63 You may distribute this code under the same terms as Perl itself.