NAME

DBIx::Class::PK::Auto - Automatic primary key class

SYNOPSIS

# In your table classes (replace PK::Auto::SQLite with your database)
__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
__PACKAGE__->set_primary_key('id');

DESCRIPTION

This class overrides the insert method to get automatically incremented primary keys.

You don't want to be using this directly - instead load the appropriate one for your database, e.g. PK::Auto::SQLite, in your table classes:

__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);

Note that PK::Auto::SQLite is specified as the leftmost argument.

Alternatively, you can load the components separately:

__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->load_components(qw/PK::Auto::SQLite/);

This can be used, for example, if you have different databases and need to determine the appropriate PK::Auto class at runtime.

LOGIC

PK::Auto does this by letting the database assign the primary key field and fetching the assigned value afterwards.

METHODS

insert

Overrides insert so that it will get the value of autoincremented primary keys.

sequence

Manually define the correct sequence for your table, to avoid the overhead associated with looking up the sequence automatically.

AUTHORS

Matt S. Trout <mst@shadowcatsystems.co.uk>

LICENSE

You may distribute this code under the same terms as Perl itself.