From: Andy Grundman Date: Fri, 26 Aug 2005 04:38:11 +0000 (+0000) Subject: Added support for multiple PKs in Auto if they are already defined during create() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0675cd04337cafdc5a8ce19e707e3b2ce2508087;p=dbsrgits%2FDBIx-Class-Historic.git Added support for multiple PKs in Auto if they are already defined during create() --- diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index 75b017b..84e679a 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -32,6 +32,12 @@ primary keys. sub insert { my ($self, @rest) = @_; my $ret = $self->NEXT::ACTUAL::insert(@rest); + + # if all primaries are already populated, skip auto-inc + my $populated = 0; + map { $populated++ if $self->$_ } keys %{ $self->_primaries }; + return $ret if ( $populated == scalar keys %{ $self->_primaries } ); + my ($pri, $too_many) = (grep { $self->_primaries->{$_}{'auto_increment'} } keys %{ $self->_primaries })