From: Simon Elliott Date: Tue, 21 Mar 2006 18:52:32 +0000 (+0000) Subject: Doc updates to remove PK::Auto:: references and miscellaneous trinkets. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=772547820db1ef7538e36902bd728c6afc11bde8;p=dbsrgits%2FDBIx-Class-Historic.git Doc updates to remove PK::Auto:: references and miscellaneous trinkets. --- diff --git a/lib/DBIx/Class/Core.pm b/lib/DBIx/Class/Core.pm index 455e741..0a319dc 100644 --- a/lib/DBIx/Class/Core.pm +++ b/lib/DBIx/Class/Core.pm @@ -49,10 +49,6 @@ The core modules currently are: =back -If you are also using a L component, please -make sure you load it correctly. Refer to -L for more information. - =head1 AUTHORS Matt S. Trout diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index f288db6..53f20ef 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -32,10 +32,8 @@ connections. __PACKAGE__->load_components(qw/Core DB/); If you want serial/auto-incrementing primary keys, you should use the -L component for your database. For example, if -you're using SQLite add C to the list: - - __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/); +L component. + __PACKAGE__->load_components(qw/PK::Auto Core DB/); C classes exist for many databases; see L for more information. diff --git a/lib/DBIx/Class/Manual/SchemaIntro.pod b/lib/DBIx/Class/Manual/SchemaIntro.pod index 1e6707e..b1275eb 100644 --- a/lib/DBIx/Class/Manual/SchemaIntro.pod +++ b/lib/DBIx/Class/Manual/SchemaIntro.pod @@ -44,9 +44,9 @@ Next, create each of the classes you want to load as specified above: Load any components required by each class with the load_components() method. This should consist of "Core" plus any additional components you want to use. -For example, if you use SQLite and want serial/auto-incrementing primary keys: +For example, if you want serial/auto-incrementing primary keys: - __PACKAGE__->load_components(qw/ PK::Auto::SQLite Core /); + __PACKAGE__->load_components(qw/ PK::Auto Core /); C classes exist for many databases; see L for more information. diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index 64c8c83..24f8810 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -11,29 +11,17 @@ DBIx::Class::PK::Auto - Automatic primary key class =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'); +__PACKAGE__->load_components(qw/PK::Auto 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. C, in your table classes: + __PACKAGE__->load_components(qw/PK::Auto Core/); - __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/); - -Note that C 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 C class at runtime. +Note that C is specified as the leftmost argument. =head1 LOGIC diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index e4ba46f..250cc5d 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -618,6 +618,22 @@ sub related_source { return $self->schema->source($self->relationship_info($rel)->{source}); } +=head2 related_class + +=head3 Arguments: ($relname) + +Returns the class object for the given relationship + +=cut + +sub related_class { + my ($self, $rel) = @_; + if( !$self->has_relationship( $rel ) ) { + $self->throw_exception("No such relationship '$rel'"); + } + return $self->schema->class($self->relationship_info($rel)->{source}); +} + =head2 resultset Returns a resultset for the given source, by calling: diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 19b49c3..efabcf4 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -26,7 +26,7 @@ DBIx::Class::Schema - composable schemas package Library::Schema::CD; use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example + __PACKAGE__->load_components(qw/PK::Auto Core/); # for example __PACKAGE__->table('cd'); # Elsewhere in your code: @@ -225,10 +225,9 @@ sub load_classes { =head3 Arguments: <@db_info> -This is the most important method in this class. it takes a target namespace, -as well as dbh connection info, and creates a L class as -well as subclasses for each of your database classes in this namespace, using -this connection. +This method takes a target namespace, as well as dbh connection info, +and creates a L class as well as subclasses for each of +your database classes in this namespace, using this connection. It will also setup a ->class method on the target class, which lets you resolve database classes based on the schema component name, for example @@ -285,6 +284,14 @@ sub compose_connection { return $schema; } +=head2 compose_namespace + +=head3 Arguments: + +Translates namespace into the specified namespace. + +=cut + sub compose_namespace { my ($self, $target, $base) = @_; my %reg = %{ $self->source_registrations }; diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index e6175b5..6893398 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -18,7 +18,7 @@ DBIx::Class::PK::Auto::SQLite - Automatic primary key class for SQLite =head1 SYNOPSIS # In your table classes - __PACKAGE__->load_components(qw/PK::Auto::SQLite Core/); + __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->set_primary_key('id'); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Test/SQLite.pm b/lib/DBIx/Class/Test/SQLite.pm index 5023e8c..97642ce 100644 --- a/lib/DBIx/Class/Test/SQLite.pm +++ b/lib/DBIx/Class/Test/SQLite.pm @@ -34,7 +34,7 @@ use strict; use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto::SQLite CDBICompat Core DB/); +__PACKAGE__->load_components(qw/PK::Auto CDBICompat Core DB/); use File::Temp qw/tempfile/; my (undef, $DB) = tempfile();