fixed pod.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / PK / Auto / Pg.pm
CommitLineData
5d567302 1package DBIx::Class::PK::Auto::Pg;
2
3use strict;
4use warnings;
5
6use base qw/DBIx::Class/;
7
8__PACKAGE__->load_components(qw/PK::Auto/);
9
10sub last_insert_id {
11 my $self=shift;
12 $self->get_autoinc_seq unless $self->{_autoinc_seq};
13 $self->storage->dbh->last_insert_id(undef,undef,undef,undef,
14 {sequence=>$self->{_autoinc_seq}});
15}
16
17sub get_autoinc_seq {
18 my $self=shift;
19 my $dbh= $self->storage->dbh;
20 my $sth = $dbh->column_info( undef, undef, $self->_table_name, '%');
21 while (my $foo = $sth->fetchrow_arrayref){
22 if(defined $foo->[12] && $foo->[12] =~ /^nextval/) {
23 ($self->{_autoinc_seq}) = $foo->[12] =~
24 m!^nextval\('"?([^"']+)"?'::text\)!;
25 }
26 }
27}
28
291;
30
31=head1 NAME
32
d00123a3 33DBIx::Class::PK::Auto::Pg- Automatic Primary Key class for Postgresql
5d567302 34
35=head1 SYNOPSIS
36
37=head1 DESCRIPTION
38
d00123a3 39This class implements autoincrements for Postgresql.
5d567302 40
41=head1 AUTHORS
42
d00123a3 43Marcus Ramberg <m.ramberg@cpan.org>
5d567302 44
45=head1 LICENSE
46
47You may distribute this code under the same terms as Perl itself.
48
49=cut
50