Added support for multiple PKs in Auto if they are already defined during create()
Andy Grundman [Fri, 26 Aug 2005 04:38:11 +0000 (04:38 +0000)]
lib/DBIx/Class/PK/Auto.pm

index 75b017b..84e679a 100644 (file)
@@ -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 })