From: Brandon Black Date: Fri, 3 Feb 2006 05:09:33 +0000 (+0000) Subject: docs fixups, C3 fixups, 0.01001 release X-Git-Tag: 0.03000~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=457eb8a66ced2572f7fec372fd633668a421b623;p=dbsrgits%2FDBIx-Class-Schema-Loader.git docs fixups, C3 fixups, 0.01001 release --- diff --git a/Changes b/Changes index de6517c..82d946d 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension DBIx::Class::Schema::Loader +0.01001 Fri Feb 3 05:15:41 UTC 2006 + - Fixed up some documentation issues + - Load C3 at the right time + 0.01 Fri Feb 3 01:53:46 UTC 2006 - original release - created from DBIx::Class::Loader 0.14 diff --git a/META.yml b/META.yml index aad02bb..92f44e7 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: DBIx-Class-Schema-Loader -version: 0.01000 +version: 0.01001 author: - 'Brandon Black, C' abstract: Dynamic definition of a DBIx::Class::Schema @@ -20,7 +20,7 @@ build_requires: provides: DBIx::Class::Schema::Loader: file: lib/DBIx/Class/Schema/Loader.pm - version: 0.01000 + version: 0.01001 DBIx::Class::Schema::Loader::DB2: file: lib/DBIx/Class/Schema/Loader/DB2.pm DBIx::Class::Schema::Loader::Generic: diff --git a/README b/README index 98bd7ae..6016355 100644 --- a/README +++ b/README @@ -41,12 +41,12 @@ SYNOPSIS # table-to-classname mappings. my $classes = $schema1->loader->classes; - # Use the schema as per normal for L + # Use the schema as per normal for DBIx::Class::Schema my $rs = $schema1->resultset($monikers->{table_table})->search(...); DESCRIPTION - THIS IS A DEVELOPMENT RELEASE. This is 0.01000, the first public - release. Expect things to be broken in various ways. Expect the entire + THIS IS A DEVELOPMENT RELEASE. This is 0.01xxx, the first public + releases. Expect things to be broken in various ways. Expect the entire design to be fatally flawed. Expect the interfaces to change if it becomes neccessary. It's mostly here for people to poke at it and find the flaws in it. 0.02 will hopefully have some sanity when we get there. @@ -60,8 +60,8 @@ DESCRIPTION DBIx::Class::Schema::Loader::Writing for notes on writing your own db-specific subclass for an unsupported db. - This module requires DBIx::Class::Loader 0.5 or later, and obsoletes - DBIx::Class::Loader for DBIx::Class version 0.5 and later. + This module requires DBIx::Class 0.05 or later, and obsoletes + DBIx::Class::Loader for DBIx::Class version 0.05 and later. METHODS load_from_connection @@ -69,6 +69,12 @@ METHODS detailed information on the arguments, see the DBIx::Class::Schema::Loader::Generic documentation. + loader + This is an accessor in the generated Schema class for accessing the + DBIx::Class::Schema::Loader::Generic -based loader object that was used + during construction. See the DBIx::Class::Schema::Loader::Generic docs + for more information on the available loader methods there. + AUTHOR Brandon Black, "bblack@gmail.com" diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 545345d..3c84204 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -2,20 +2,18 @@ package DBIx::Class::Schema::Loader; use strict; use warnings; -use Carp; -use UNIVERSAL::require; - use base qw/DBIx::Class::Schema/; use base qw/Class::Data::Accessor/; - -__PACKAGE__->mk_classaccessor('loader'); - -use vars qw($VERSION); +use Carp; +use UNIVERSAL::require; # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -$VERSION = '0.01000'; +use vars qw($VERSION); +$VERSION = '0.01001'; + +__PACKAGE__->mk_classaccessor('loader'); =head1 NAME @@ -61,13 +59,13 @@ DBIx::Class::Schema::Loader - Dynamic definition of a DBIx::Class::Schema # table-to-classname mappings. my $classes = $schema1->loader->classes; - # Use the schema as per normal for L + # Use the schema as per normal for DBIx::Class::Schema my $rs = $schema1->resultset($monikers->{table_table})->search(...); =head1 DESCRIPTION -THIS IS A DEVELOPMENT RELEASE. This is 0.01000, the first public -release. Expect things to be broken in various ways. Expect the +THIS IS A DEVELOPMENT RELEASE. This is 0.01xxx, the first public +releases. Expect things to be broken in various ways. Expect the entire design to be fatally flawed. Expect the interfaces to change if it becomes neccessary. It's mostly here for people to poke at it and find the flaws in it. 0.02 will hopefully have some sanity when we get @@ -82,10 +80,8 @@ L for more, and L for notes on writing your own db-specific subclass for an unsupported db. -This module requires DBIx::Class::Loader 0.5 or later, and obsoletes -L for L version 0.5 and later. - -=cut +This module requires L 0.05 or later, and obsoletes +L for L version 0.05 and later. =head1 METHODS @@ -116,6 +112,14 @@ sub load_from_connection { $class->loader->load; } +=head2 loader + +This is an accessor in the generated Schema class for accessing +the L -based loader object +that was used during construction. See the +L docs for more information +on the available loader methods there. + =head1 AUTHOR Brandon Black, C diff --git a/lib/DBIx/Class/Schema/Loader/DB2.pm b/lib/DBIx/Class/Schema/Loader/DB2.pm index fd56322..4555dc2 100644 --- a/lib/DBIx/Class/Schema/Loader/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DB2.pm @@ -2,8 +2,8 @@ package DBIx::Class::Schema::Loader::DB2; use strict; use warnings; -use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; +use Class::C3; =head1 NAME @@ -11,10 +11,10 @@ DBIx::Class::Schema::Loader::DB2 - DBIx::Class::Schema::Loader DB2 Implementatio =head1 SYNOPSIS - use DBIx::Schema::Class::Loader; + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; - # $loader is a DBIx::Class::Schema::Loader::DB2 - my $loader = DBIx::Class::Schema::Loader->new( + __PACKAGE__->load_from_connection( dsn => "dbi:DB2:dbname", user => "myuser", password => "", @@ -22,6 +22,8 @@ DBIx::Class::Schema::Loader::DB2 - DBIx::Class::Schema::Loader DB2 Implementatio drop_schema => 1, ); + 1; + =head1 DESCRIPTION See L. diff --git a/lib/DBIx/Class/Schema/Loader/Generic.pm b/lib/DBIx/Class/Schema/Loader/Generic.pm index 549be17..373c725 100644 --- a/lib/DBIx/Class/Schema/Loader/Generic.pm +++ b/lib/DBIx/Class/Schema/Loader/Generic.pm @@ -2,12 +2,10 @@ package DBIx::Class::Schema::Loader::Generic; use strict; use warnings; +use base qw/Class::Accessor::Fast/; use Class::C3; - use Carp; use Lingua::EN::Inflect; -use base qw/Class::Accessor::Fast/; - require DBIx::Class::Core; # The first group are all arguments which are may be defaulted within, @@ -44,68 +42,59 @@ See L =head1 DESCRIPTION -=head2 OPTIONS +This is the base class for the vendor-specific C +classes, and implements the common functionality between them. + +=head1 OPTIONS Available constructor options are: -=head3 additional_base_classes +=head2 additional_base_classes List of additional base classes your table classes will use. -=head3 left_base_classes +=head2 left_base_classes List of additional base classes, that need to be leftmost. -=head3 additional_classes +=head2 additional_classes List of additional classes which your table classes will use. -=head3 constraint +=head2 constraint Only load tables matching regex. -=head3 exclude +=head2 exclude Exclude tables matching regex. -=head3 debug +=head2 debug Enable debug messages. -=head3 dsn +=head2 dsn DBI Data Source Name. -=head3 password +=head2 password Password. -=head3 relationships +=head2 relationships Try to automatically detect/setup has_a and has_many relationships. -=head3 inflect +=head2 inflect An hashref, which contains exceptions to Lingua::EN::Inflect::PL(). Useful for foreign language column names. -=head3 user +=head2 user Username. -=head2 METHODS - -=cut - -=head3 new - -Constructor for L, used internally -by L. - -=head3 load - -Does the actual schema-construction work, used internally by -L right after object construction. +=head1 METHODS =cut @@ -121,6 +110,13 @@ sub _ensure_arrayref { } } +=head2 new + +Constructor for L, used internally +by L. + +=cut + sub new { my ( $class, %args ) = @_; @@ -141,6 +137,13 @@ sub new { $self; } +=head2 load + +Does the actual schema-construction work, used internally by +L right after object construction. + +=cut + sub load { my $self = shift; @@ -318,38 +321,12 @@ sub _load_classes { } } -=head3 tables +=head2 tables Returns a sorted list of loaded tables, using the original database table names. Actually generated from the keys of the C hash below. - my @tables = $schema->loader->tables; - -=head3 monikers - -Returns a hashref of loaded table-to-moniker mappings for the original -database table names. - - my $monikers = $schema->loader->monikers; - my $foo_tbl_moniker = $monikers->{foo_tbl}; - # -or- - my $foo_tbl_moniker = $schema->loader->monikers->{foo_tbl}; - # $foo_tbl_moniker would look like "FooTbl" - -=head3 classes - -Returns a hashref of table-to-classname mappings for the original database -table names. You probably shouldn't be using this for any normal or simple -usage of your Schema. The usual way to run queries on your tables is via -C<$schema-Eresultset('FooTbl')>, where C is a moniker as -returned by C above. - - my $classes = $schema->loader->classes; - my $foo_tbl_class = $classes->{foo_tbl}; - # -or- - my $foo_tbl_class = $schema->loader->classes->{foo_tbl}; - # $foo_tbl_class would look like "My::Schema::FooTbl", - # assuming the schema class is "My::Schema" + my @tables = $schema->loader->tables; =cut @@ -417,6 +394,32 @@ sub _tables { croak "ABSTRACT METHOD" } sub _table_info { croak "ABSTRACT METHOD" } +=head2 monikers + +Returns a hashref of loaded table-to-moniker mappings for the original +database table names. + + my $monikers = $schema->loader->monikers; + my $foo_tbl_moniker = $monikers->{foo_tbl}; + # -or- + my $foo_tbl_moniker = $schema->loader->monikers->{foo_tbl}; + # $foo_tbl_moniker would look like "FooTbl" + +=head2 classes + +Returns a hashref of table-to-classname mappings for the original database +table names. You probably shouldn't be using this for any normal or simple +usage of your Schema. The usual way to run queries on your tables is via +C<$schema-Eresultset('FooTbl')>, where C is a moniker as +returned by C above. + + my $classes = $schema->loader->classes; + my $foo_tbl_class = $classes->{foo_tbl}; + # -or- + my $foo_tbl_class = $schema->loader->classes->{foo_tbl}; + # $foo_tbl_class would look like "My::Schema::FooTbl", + # assuming the schema class is "My::Schema" + =head1 SEE ALSO L diff --git a/lib/DBIx/Class/Schema/Loader/Pg.pm b/lib/DBIx/Class/Schema/Loader/Pg.pm index ec4a221..640b43a 100644 --- a/lib/DBIx/Class/Schema/Loader/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/Pg.pm @@ -3,7 +3,6 @@ package DBIx::Class::Schema::Loader::Pg; use strict; use warnings; use Class::C3; - use base 'DBIx::Class::Schema::Loader::Generic'; =head1 NAME @@ -12,22 +11,24 @@ DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implement =head1 SYNOPSIS - use DBIx::Class::Schema::Loader; + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; - # $loader is a DBIx::Class::Schema::Loader::Pg - my $loader = DBIx::Class::Schema::Loader->new( + __PACKAGE__->load_from_connection( dsn => "dbi:Pg:dbname=dbname", user => "postgres", password => "", ); + 1; + =head1 DESCRIPTION See L. =head1 METHODS -=head3 new +=head2 new Overrides L's C to default the postgres schema to C rather than blank. diff --git a/lib/DBIx/Class/Schema/Loader/SQLite.pm b/lib/DBIx/Class/Schema/Loader/SQLite.pm index 7291632..1469923 100644 --- a/lib/DBIx/Class/Schema/Loader/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/SQLite.pm @@ -2,9 +2,8 @@ package DBIx::Class::Schema::Loader::SQLite; use strict; use warnings; -use Class::C3; use base qw/DBIx::Class::Schema::Loader::Generic/; - +use Class::C3; use Text::Balanced qw( extract_bracketed ); =head1 NAME @@ -13,13 +12,15 @@ DBIx::Class::Schema::Loader::SQLite - DBIx::Class::Schema::Loader SQLite Impleme =head1 SYNOPSIS - use DBIx::Class::Schema::Loader; + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; - # $loader is a DBIx::Class::Schema::Loader::SQLite - my $loader = DBIx::Class::Schema::Loader->new( + __PACKAGE__->load_from_connection( dsn => "dbi:SQLite:dbname=/path/to/dbfile", ); + 1; + =head1 DESCRIPTION See L. diff --git a/lib/DBIx/Class/Schema/Loader/Writing.pm b/lib/DBIx/Class/Schema/Loader/Writing.pm index a350a10..d0117a5 100644 --- a/lib/DBIx/Class/Schema/Loader/Writing.pm +++ b/lib/DBIx/Class/Schema/Loader/Writing.pm @@ -16,8 +16,8 @@ DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide use strict; use warnings; - use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; + use Class::C3; sub _db_classes { return qw/DBIx::Class::PK::Auto::Foo/; @@ -51,4 +51,6 @@ DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide ... } + 1; + =cut diff --git a/lib/DBIx/Class/Schema/Loader/mysql.pm b/lib/DBIx/Class/Schema/Loader/mysql.pm index 6072365..b3aaafd 100644 --- a/lib/DBIx/Class/Schema/Loader/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/mysql.pm @@ -2,8 +2,8 @@ package DBIx::Class::Schema::Loader::mysql; use strict; use warnings; -use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; +use Class::C3; =head1 NAME @@ -11,15 +11,17 @@ DBIx::Class::Schema::Loader::mysql - DBIx::Schema::Class::Loader mysql Implement =head1 SYNOPSIS - use DBIx::Class::Schema::Loader; + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; - # $loader is a DBIx::Class::Schema::Loader::mysql - my $loader = DBIx::Class::Schema::Loader->new( + __PACKAGE__->load_from_connection( dsn => "dbi:mysql:dbname", user => "root", password => "", ); + 1; + =head1 DESCRIPTION See L.