Commit | Line | Data |
---|---|---|
b8e1e21f | 1 | package DBIx::Class::PK::Auto; |
2 | ||
773e3015 | 3 | #use base qw/DBIx::Class::PK/; |
4 | use base qw/DBIx::Class/; | |
b8e1e21f | 5 | use strict; |
6 | use warnings; | |
7 | ||
75d07914 | 8 | =head1 NAME |
34d52be2 | 9 | |
eb49d4e3 | 10 | DBIx::Class::PK::Auto - Automatic primary key class |
34d52be2 | 11 | |
12 | =head1 SYNOPSIS | |
13 | ||
d88ecca6 | 14 | use base 'DBIx::Class::Core'; |
77254782 | 15 | __PACKAGE__->set_primary_key('id'); |
6718c5f0 | 16 | |
34d52be2 | 17 | =head1 DESCRIPTION |
18 | ||
eb49d4e3 | 19 | This class overrides the insert method to get automatically incremented primary |
20 | keys. | |
34d52be2 | 21 | |
9ea86671 | 22 | PK::Auto is now part of Core. |
f4ccda68 | 23 | |
e2441ae6 | 24 | See L<DBIx::Class::Manual::Component> for details of component interactions. |
7624b19f | 25 | |
c8f4b52b | 26 | =head1 LOGIC |
27 | ||
eb49d4e3 | 28 | C<PK::Auto> does this by letting the database assign the primary key field and |
29 | fetching the assigned value afterwards. | |
c8f4b52b | 30 | |
34d52be2 | 31 | =head1 METHODS |
32 | ||
130c6439 | 33 | =head2 insert |
34d52be2 | 34 | |
9ea86671 | 35 | The code that was handled here is now in Row for efficiency. |
b8e1e21f | 36 | |
130c6439 | 37 | =head2 sequence |
97cc0025 | 38 | |
39 | Manually define the correct sequence for your table, to avoid the overhead | |
40 | associated with looking up the sequence automatically. | |
41 | ||
42 | =cut | |
43 | ||
ecb6488f | 44 | sub sequence { |
45 | my ($self,$seq) = @_; | |
46 | foreach my $pri ($self->primary_columns) { | |
47 | $self->column_info($pri)->{sequence} = $seq; | |
48 | } | |
49 | } | |
97cc0025 | 50 | |
b8e1e21f | 51 | 1; |
34d52be2 | 52 | |
34d52be2 | 53 | =head1 AUTHORS |
54 | ||
daec44b8 | 55 | Matt S. Trout <mst@shadowcatsystems.co.uk> |
34d52be2 | 56 | |
57 | =head1 LICENSE | |
58 | ||
59 | You may distribute this code under the same terms as Perl itself. | |
60 | ||
61 | =cut |