From: Andy Grundman Date: Tue, 9 Aug 2005 00:37:34 +0000 (+0000) Subject: Added sequence method to PK::Auto X-Git-Tag: v0.03001~47 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=97cc0025be6018be97a760b3ff9b8090d91d0baa;p=dbsrgits%2FDBIx-Class.git Added sequence method to PK::Auto --- diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index 43a1ece..75b017b 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -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 diff --git a/lib/DBIx/Class/PK/Auto/Pg.pm b/lib/DBIx/Class/PK/Auto/Pg.pm index 549da4b..eb6856c 100644 --- a/lib/DBIx/Class/PK/Auto/Pg.pm +++ b/lib/DBIx/Class/PK/Auto/Pg.pm @@ -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){