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