Applied Brandon Black's patch to PK::Auto::Pg
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / PK / Auto / Pg.pm
index 549da4b..ab401f8 100644 (file)
@@ -16,12 +16,18 @@ sub last_insert_id {
 
 sub get_autoinc_seq {
   my $self=shift;
+  
+  # return the user-defined sequence if known
+  if ($self->sequence) {
+    return $self->{_autoinc_seq} = $self->sequence;
+  }
+  
   my $dbh= $self->storage->dbh;
     my $sth    = $dbh->column_info( undef, undef, $self->_table_name, '%');
     while (my $foo = $sth->fetchrow_arrayref){
       if(defined $foo->[12] && $foo->[12] =~ /^nextval/) {
         ($self->{_autoinc_seq}) = $foo->[12] =~ 
-         m!^nextval\('"?([^"']+)"?'::text\)!;
+          m!^nextval\('"?([^"']+)"?'::(?:text|regclass)\)!;
       }
     }
 }
@@ -30,7 +36,7 @@ sub get_autoinc_seq {
 
 =head1 NAME 
 
-DBIx::Class::PK::Auto::Pg- Automatic Primary Key class for Postgresql
+DBIx::Class::PK::Auto::Pg - Automatic Primary Key class for Postgresql
 
 =head1 SYNOPSIS