From: Simon Elliott Date: Tue, 21 Mar 2006 18:35:23 +0000 (+0000) Subject: undo changes that should have been in TRUNK. /me thwaps self X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d701f86fb5c2681cf99ff64cc6c42000376b675;p=dbsrgits%2FDBIx-Class-Historic.git undo changes that should have been in TRUNK. /me thwaps self --- diff --git a/lib/DBIx/Class/Core.pm b/lib/DBIx/Class/Core.pm index 0a319dc..455e741 100644 --- a/lib/DBIx/Class/Core.pm +++ b/lib/DBIx/Class/Core.pm @@ -49,6 +49,10 @@ 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 53f20ef..f288db6 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -32,8 +32,10 @@ connections. __PACKAGE__->load_components(qw/Core DB/); If you want serial/auto-incrementing primary keys, you should use the -L component. - __PACKAGE__->load_components(qw/PK::Auto Core DB/); +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/); 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 b1275eb..1e6707e 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 want serial/auto-incrementing primary keys: +For example, if you use SQLite and want serial/auto-incrementing primary keys: - __PACKAGE__->load_components(qw/ PK::Auto Core /); + __PACKAGE__->load_components(qw/ PK::Auto::SQLite 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 24f8810..64c8c83 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -11,17 +11,29 @@ DBIx::Class::PK::Auto - Automatic primary key class =head1 SYNOPSIS -__PACKAGE__->load_components(qw/PK::Auto Core/); -__PACKAGE__->set_primary_key('id'); + # 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. - __PACKAGE__->load_components(qw/PK::Auto Core/); +You don't want to be using this directly - instead load the appropriate one for +your database, e.g. C, in your table classes: -Note that C is specified as the leftmost argument. + __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. =head1 LOGIC diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 250cc5d..e4ba46f 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -618,22 +618,6 @@ 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 fde0c11..19b49c3 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 Core/); # for example + __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example __PACKAGE__->table('cd'); # Elsewhere in your code: @@ -225,9 +225,10 @@ sub load_classes { =head3 Arguments: <@db_info> -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. +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. 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 @@ -284,19 +285,6 @@ sub compose_connection { return $schema; } -=head2 compose_namespace - -=head3 Arguments: - -Translates namespace into the specified namespace. -For example - - My::Schema->compose_connection('A::B::C', @conn_info); - -My::Schema::Tableclasses would become A::B::C::Tableclasses. - -=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 6893398..e6175b5 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 Core/); + __PACKAGE__->load_components(qw/PK::Auto::SQLite 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 97642ce..5023e8c 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 CDBICompat Core DB/); +__PACKAGE__->load_components(qw/PK::Auto::SQLite CDBICompat Core DB/); use File::Temp qw/tempfile/; my (undef, $DB) = tempfile();