Added sequence method to PK::Auto
Andy Grundman [Tue, 9 Aug 2005 00:37:34 +0000 (00:37 +0000)]
lib/DBIx/Class/PK/Auto.pm
lib/DBIx/Class/PK/Auto/Pg.pm

index 43a1ece..75b017b 100644 (file)
@@ -1,5 +1,6 @@
 package DBIx::Class::PK::Auto;
 
+use base qw/Class::Data::Inheritable/;
 use strict;
 use warnings;
 
@@ -47,6 +48,15 @@ sub insert {
   return $ret;
 }
 
+=item sequence
+
+Manually define the correct sequence for your table, to avoid the overhead
+associated with looking up the sequence automatically.
+
+=cut
+
+__PACKAGE__->mk_classdata('sequence');
+
 1;
 
 =back
index 549da4b..eb6856c 100644 (file)
@@ -16,6 +16,10 @@ sub last_insert_id {
 
 sub get_autoinc_seq {
   my $self=shift;
+  
+  # return the user-defined sequence if known
+  return $self->sequence if ($self->sequence);
+  
   my $dbh= $self->storage->dbh;
     my $sth    = $dbh->column_info( undef, undef, $self->_table_name, '%');
     while (my $foo = $sth->fetchrow_arrayref){