[Dbix-class] [Patch] PK::Auto documentation

Daniel Westermann-Clark daniel at acceleration.net
Thu Dec 15 23:32:35 CET 2005


Since the question seems to come up pretty often, here's a patch
against trunk describing basic usage of the PK::Auto classes.

Each PK::Auto::$database class has a synopsis, as does PK::Auto.  The
patch also explicitly notes that the PK::Auto::$database class should
be loaded before Core.

-- 
Daniel Westermann-Clark
-------------- next part --------------
Patching locally against mirror source http://dev.catalyst.perl.org/repos/bast.
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto.pm
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MySQL.pm
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Oracle.pm
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Pg.pm
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MSSQL.pm
U   trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/SQLite.pm
==== Patch <-> level 1
Source: [No source]
Target: bd8105ee-0ff8-0310-8827-fb3f25b6796d:/:397
        (http://dev.catalyst.perl.org/repos/bast)
Log:
Provide synopses for PK::Auto classes
=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto.pm	(patch - level 1)
@@ -11,18 +11,24 @@
 
 =head1 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');
+
 =head1 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
+You don't want to be using this directly - instead load the
+appropriate one for your database, e.g. C<PK::Auto::SQLite>, before
+C<Core>.
 
 =head1 LOGIC
 
-PK::Auto does this by letting the database assign the primary key field
-and fetching the assigned value afterwards.
+PK::Auto does this by letting the database assign the primary key
+field and fetching the assigned value afterwards.
 
 =head1 METHODS
 
=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MySQL.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MySQL.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MySQL.pm	(patch - level 1)
@@ -19,6 +19,10 @@
 
 =head1 SYNOPSIS
 
+    # In your table classes
+    __PACKAGE__->load_components(qw/PK::Auto::MySQL Core/);
+    __PACKAGE__->set_primary_key('id');
+
 =head1 DESCRIPTION
 
 This class implements autoincrements for MySQL.
=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Oracle.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Oracle.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Oracle.pm	(patch - level 1)
@@ -53,6 +53,10 @@
 
 =head1 SYNOPSIS
 
+    # In your table classes
+    __PACKAGE__->load_components(qw/PK::Auto::Oracle Core/);
+    __PACKAGE__->set_primary_key('id');
+
 =head1 DESCRIPTION
 
 This class implements autoincrements for Oracle.
=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Pg.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Pg.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/Pg.pm	(patch - level 1)
@@ -43,6 +43,10 @@
 
 =head1 SYNOPSIS
 
+    # In your table classes
+    __PACKAGE__->load_components(qw/PK::Auto::Pg Core/);
+    __PACKAGE__->set_primary_key('id');
+
 =head1 DESCRIPTION
 
 This class implements autoincrements for Postgresql.
=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MSSQL.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MSSQL.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/MSSQL.pm	(patch - level 1)
@@ -20,6 +20,10 @@
 

 =head1 SYNOPSIS

 

+    # In your table classes

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

+    __PACKAGE__->set_primary_key('id');

+

 =head1 DESCRIPTION

 

 This class implements autoincrements for MSSQL.

@@ -32,4 +36,4 @@
 

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

 

-=cut
\ No newline at end of file
+=cut

=== trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/SQLite.pm
==================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/SQLite.pm	(revision 397)
+++ trunk/DBIx-Class/lib/DBIx/Class/PK/Auto/SQLite.pm	(patch - level 1)
@@ -19,6 +19,10 @@
 
 =head1 SYNOPSIS
 
+    # In your table classes
+    __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
+    __PACKAGE__->set_primary_key('id');
+
 =head1 DESCRIPTION
 
 This class implements autoincrements for SQLite.

==== BEGIN SVK PATCH BLOCK ====
Version: svk 1.05 (linux)

eJytl+9v00YYxz3tXRjvtr22tiCKRpr7ad8VFoV1wBBshJVNGhqKzr7nUgs3zhy3kMkTTQZCq7Zp
f/LO5zZQcNOCGuXN2fd8nuf5+nnux6384bU+Lns9VLYxKrd+vruxMVBFvH3JjtpBCTopsrzNyxT2
IG3TMs1GbVaO1Q7Yt4XKR1D0etgai9r4pjM4grCKEakiG0/b0sGGRQ7QJiVmfczLPq3+wzaW5RTs
O8cb5rCXTJNsbB1RTLid0cYltoBsAuNhnmWFDYTKsE8qU1TGaTaFYUW3T/q8mk3amNXTdZJDbEOa
2SSKfHf8xLFqe+eaH9q/nmgnLEG0AYSDmtT99ps7zzqbqZpOnctToGQJZQ1Qgt6BdtMkciGcAqZL
MG8C80awG7pYTqGzJT1ooFN8Mr17JA0/zQdf+gibfLDTfHQHd118p7gJqnpzbsRRNZkkhTYjZ3DQ
vbFbZOuTHRdk7cihZFPE8qzAN2gnhh3W6ri3ajJJZ8MCnhUa0kK5VCgpOSHAYgk6DsIoJKE2QAJl
YhQQHIRIt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qb3oaIERB+ggY0QHUYw6QpCwYyJqCI+CUAb6f4CPR1Q=
==== END SVK PATCH BLOCK ====


More information about the Dbix-class mailing list