1 package DBIx::Class::PK::Auto;
8 DBIx::Class::PK::Auto - Automatic Primary Key class
14 This class overrides the insert method to get automatically
15 incremented primary keys.
23 Overrides insert so that it will get the value of autoincremented
29 my ($self, @rest) = @_;
30 my $ret = $self->NEXT::ACTUAL::insert(@rest);
31 my ($pri, $too_many) =
32 (grep { $self->_primaries->{$_}{'auto_increment'} }
33 keys %{ $self->_primaries })
34 || (keys %{ $self->_primaries });
35 die "More than one possible key found for auto-inc on ".ref $self
37 unless (defined $self->get_column($pri)) {
38 die "Can't auto-inc for $pri on ".ref $self.": no _last_insert_id method"
39 unless $self->can('_last_insert_id');
40 my $id = $self->_last_insert_id;
41 die "Can't get last insert id" unless $id;
42 $self->store_column($pri => $id);
53 Matt S. Trout <perl-stuff@trout.me.uk>
57 You may distribute this code under the same terms as Perl itself.