From: Peter Rabbitson Date: Wed, 9 Dec 2009 01:33:30 +0000 (+0000) Subject: It's almost 2010 - load_components ('Core') is like ewwww X-Git-Tag: v0.08116~105 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d88ecca6486a2b1c4b6e2f0440165b186aab39bc;p=dbsrgits%2FDBIx-Class.git It's almost 2010 - load_components ('Core') is like ewwww --- diff --git a/examples/Schema/MyDatabase/Main/Result/Artist.pm b/examples/Schema/MyDatabase/Main/Result/Artist.pm index ec78501..0571dae 100644 --- a/examples/Schema/MyDatabase/Main/Result/Artist.pm +++ b/examples/Schema/MyDatabase/Main/Result/Artist.pm @@ -1,9 +1,16 @@ package MyDatabase::Main::Result::Artist; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); + +use warnings; +use strict; + +use base qw/DBIx::Class::Core/; + __PACKAGE__->table('artist'); + __PACKAGE__->add_columns(qw/ artistid name /); + __PACKAGE__->set_primary_key('artistid'); + __PACKAGE__->has_many('cds' => 'MyDatabase::Main::Result::Cd'); 1; diff --git a/examples/Schema/MyDatabase/Main/Result/Cd.pm b/examples/Schema/MyDatabase/Main/Result/Cd.pm index 83fd21e..6a465a1 100644 --- a/examples/Schema/MyDatabase/Main/Result/Cd.pm +++ b/examples/Schema/MyDatabase/Main/Result/Cd.pm @@ -1,9 +1,16 @@ package MyDatabase::Main::Result::Cd; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); + +use warnings; +use strict; + +use base qw/DBIx::Class::Core/; + __PACKAGE__->table('cd'); + __PACKAGE__->add_columns(qw/ cdid artist title/); + __PACKAGE__->set_primary_key('cdid'); + __PACKAGE__->belongs_to('artist' => 'MyDatabase::Main::Result::Artist'); __PACKAGE__->has_many('tracks' => 'MyDatabase::Main::Result::Track'); diff --git a/examples/Schema/MyDatabase/Main/Result/Track.pm b/examples/Schema/MyDatabase/Main/Result/Track.pm index 23877bb..961018b 100644 --- a/examples/Schema/MyDatabase/Main/Result/Track.pm +++ b/examples/Schema/MyDatabase/Main/Result/Track.pm @@ -1,9 +1,16 @@ package MyDatabase::Main::Result::Track; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); + +use warnings; +use strict; + +use base qw/DBIx::Class::Core/; + __PACKAGE__->table('track'); + __PACKAGE__->add_columns(qw/ trackid cd title/); + __PACKAGE__->set_primary_key('trackid'); + __PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Result::Cd'); 1; diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 07b678c..f706a64 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -78,9 +78,8 @@ MyDB/Schema/Result/Artist.pm: See L for docs on defining result classes. package MyDB::Schema::Result::Artist; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('artist'); __PACKAGE__->add_columns(qw/ artistid name /); __PACKAGE__->set_primary_key('artistid'); @@ -92,9 +91,9 @@ A result class to represent a CD, which belongs to an artist, in MyDB/Schema/Result/CD.pm: package MyDB::Schema::Result::CD; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components(qw/Core/); + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->table('cd'); __PACKAGE__->add_columns(qw/ cdid artistid title year /); __PACKAGE__->set_primary_key('cdid'); diff --git a/lib/DBIx/Class/Core.pm b/lib/DBIx/Class/Core.pm index d4d980a..99e1624 100644 --- a/lib/DBIx/Class/Core.pm +++ b/lib/DBIx/Class/Core.pm @@ -22,8 +22,8 @@ DBIx::Class::Core - Core set of DBIx::Class modules =head1 SYNOPSIS - # In your table classes - __PACKAGE__->load_components(qw/Core/); + # In your result (table) classes + use base 'DBIx::Class::Core'; =head1 DESCRIPTION diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index 38ea045..06f6ffc 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -178,7 +178,7 @@ sub store_inflated_column { =over 4 =item L - This component is loaded as part of the - "core" L components; generally there is no need to + C L components; generally there is no need to load it directly =back diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 2b40608..50c66a1 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -15,15 +15,14 @@ Load this component and then declare one or more columns to be of the datetime, timestamp or date datatype. package Event; - __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); + use base 'DBIx::Class::Core'; + + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->add_columns( starts_when => { data_type => 'datetime' } create_date => { data_type => 'date' } ); -NOTE: You B load C B C. See -L for details. - Then you can treat the specified column as a L object. print "This event starts the month of ". diff --git a/lib/DBIx/Class/InflateColumn/File.pm b/lib/DBIx/Class/InflateColumn/File.pm index 1901187..0fde5e8 100644 --- a/lib/DBIx/Class/InflateColumn/File.pm +++ b/lib/DBIx/Class/InflateColumn/File.pm @@ -113,7 +113,9 @@ DBIx::Class::InflateColumn::File - map files from the Database to the filesyste In your L table class: - __PACKAGE__->load_components( "PK::Auto", "InflateColumn::File", "Core" ); + use base 'DBIx::Class::Core'; + + __PACKAGE__->load_components(qw/InflateColumn::File/); # define your columns __PACKAGE__->add_columns( diff --git a/lib/DBIx/Class/Manual/Component.pod b/lib/DBIx/Class/Manual/Component.pod index b8da6f7..2a762f8 100644 --- a/lib/DBIx/Class/Manual/Component.pod +++ b/lib/DBIx/Class/Manual/Component.pod @@ -12,31 +12,29 @@ itself creates, after the insert has happened. =head1 USING -Components are loaded using the load_components() method within your +Components are loaded using the load_components() method within your DBIx::Class classes. package My::Thing; - use base qw( DBIx::Class ); - __PACKAGE__->load_components(qw/ PK::Auto Core /); + use base qw( DBIx::Class::Core ); + __PACKAGE__->load_components(qw/InflateColumn::DateTime TimeStamp/); -Generally you do not want to specify the full package name -of a component, instead take off the DBIx::Class:: part of -it and just include the rest. If you do want to load a -component outside of the normal namespace you can do so +Generally you do not want to specify the full package name +of a component, instead take off the DBIx::Class:: part of +it and just include the rest. If you do want to load a +component outside of the normal namespace you can do so by prepending the component name with a +. __PACKAGE__->load_components(qw/ +My::Component /); -Once a component is loaded all of it's methods, or otherwise, +Once a component is loaded all of it's methods, or otherwise, that it provides will be available in your class. -The order in which is you load the components may be -very important, depending on the component. The general -rule of thumb is to first load extra components and then -load core ones last. If you are not sure, then read the -docs for the components you are using and see if they -mention anything about the order in which you should load -them. +The order in which is you load the components may be very +important, depending on the component. If you are not sure, +then read the docs for the components you are using and see +if they mention anything about the order in which you should +load them. =head1 CREATING COMPONENTS @@ -47,11 +45,11 @@ Making your own component is very easy. # Create methods, accessors, load other components, etc. 1; -When a component is loaded it is included in the calling -class' inheritance chain using L. As well as -providing custom utility methods, a component may also -override methods provided by other core components, like -L and others. For example, you +When a component is loaded it is included in the calling +class' inheritance chain using L. As well as +providing custom utility methods, a component may also +override methods provided by other core components, like +L and others. For example, you could override the insert and delete methods. sub insert { @@ -108,22 +106,22 @@ L - CRUD methods. =head2 Experimental -These components are under development, there interfaces may -change, they may not work, etc. So, use them if you want, but +These components are under development, there interfaces may +change, they may not work, etc. So, use them if you want, but be warned. L - Validate all data before submitting to your database. =head2 Core -These are the components that all, or nearly all, people will use -without even knowing it. These components provide most of +These are the components that all, or nearly all, people will use +without even knowing it. These components provide most of DBIx::Class' functionality. -L - Lets you build groups of accessors. - L - Loads various components that "most people" would want. +L - Lets you build groups of accessors. + L - Non-recommended classdata schema component. L - Automatically create objects from column data. diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 7002b54..ddac04a 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -113,9 +113,8 @@ almost like you would define a regular ResultSource. package My::Schema::Result::UserFriendsComplex; use strict; use warnings; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components('Core'); __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); # ->table, ->add_columns, etc. @@ -395,7 +394,7 @@ To use your resultset, first tell DBIx::Class to create an instance of it for you, in your My::DBIC::Schema::CD class: # class definition as normal - __PACKAGE__->load_components(qw/ Core /); + use base 'DBIx::Class::Core'; __PACKAGE__->table('cd'); # tell DBIC to use the custom ResultSet class @@ -842,13 +841,11 @@ B use strict; use warnings; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; ### Define what our admin class is, for ensure_class_loaded() my $admin_class = __PACKAGE__ . '::Admin'; - __PACKAGE__->load_components(qw/Core/); - __PACKAGE__->table('users'); __PACKAGE__->add_columns(qw/user_id email password @@ -1090,8 +1087,7 @@ If you want to get a filtered result set, you can just add add to $attr as follo This is straightforward using L: package My::User; - use base 'DBIx::Class'; - __PACKAGE__->load_components('Core'); + use base 'DBIx::Class::Core'; __PACKAGE__->table('user'); __PACKAGE__->add_columns(qw/id name/); __PACKAGE__->set_primary_key('id'); @@ -1099,8 +1095,7 @@ This is straightforward using Lmany_to_many('addresses' => 'user_address', 'address'); package My::UserAddress; - use base 'DBIx::Class'; - __PACKAGE__->load_components('Core'); + use base 'DBIx::Class::Core'; __PACKAGE__->table('user_address'); __PACKAGE__->add_columns(qw/user address/); __PACKAGE__->set_primary_key(qw/user address/); @@ -1108,8 +1103,7 @@ This is straightforward using Lbelongs_to('address' => 'My::Address'); package My::Address; - use base 'DBIx::Class'; - __PACKAGE__->load_components('Core'); + use base 'DBIx::Class::Core'; __PACKAGE__->table('address'); __PACKAGE__->add_columns(qw/id street town area_code country/); __PACKAGE__->set_primary_key('id'); @@ -1140,8 +1134,7 @@ To accomplish this one only needs to specify the DB schema name in the table declaration, like so... package MyDatabase::Main::Artist; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/PK::Auto Core/); + use base qw/DBIx::Class::Core/; __PACKAGE__->table('database1.artist'); # will use "database1.artist" in FROM clause @@ -1426,8 +1419,7 @@ Make a table class as you would for any other table package MyAppDB::Dual; use strict; use warnings; - use base 'DBIx::Class'; - __PACKAGE__->load_components("Core"); + use base 'DBIx::Class::Core'; __PACKAGE__->table("Dual"); __PACKAGE__->add_columns( "dummy", @@ -2012,15 +2004,15 @@ details on creating static schemas from a database). Typically L result classes start off with - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); + use base qw/DBIx::Class::Core/; + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); If this preamble is moved into a common base class:- package MyDBICbase; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); + use base qw/DBIx::Class::Core/; + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); 1; and each result class then uses this as a base:- diff --git a/lib/DBIx/Class/Manual/Example.pod b/lib/DBIx/Class/Manual/Example.pod index 5d8980f..8371c7f 100644 --- a/lib/DBIx/Class/Manual/Example.pod +++ b/lib/DBIx/Class/Manual/Example.pod @@ -89,8 +89,7 @@ MyDatabase/Main.pm: MyDatabase/Main/Result/Artist.pm: package MyDatabase::Main::Result::Artist; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/Core/); + use base qw/DBIx::Class::Core/; __PACKAGE__->table('artist'); __PACKAGE__->add_columns(qw/ artistid name /); __PACKAGE__->set_primary_key('artistid'); @@ -102,8 +101,8 @@ MyDatabase/Main/Result/Artist.pm: MyDatabase/Main/Result/Cd.pm: package MyDatabase::Main::Result::Cd; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/Core/); + use base qw/DBIx::Class::Core/; + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); __PACKAGE__->table('cd'); __PACKAGE__->add_columns(qw/ cdid artist title/); __PACKAGE__->set_primary_key('cdid'); @@ -116,10 +115,9 @@ MyDatabase/Main/Result/Cd.pm: MyDatabase/Main/Result/Track.pm: package MyDatabase::Main::Result::Track; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/Core/); + use base qw/DBIx::Class::Core/; __PACKAGE__->table('track'); - __PACKAGE__->add_columns(qw/ trackid cd title/); + __PACKAGE__->add_columns(qw/ trackid cd title /); __PACKAGE__->set_primary_key('trackid'); __PACKAGE__->belongs_to('cd' => 'MyDatabase::Main::Result::Cd'); diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index fa33614..4625d06 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -105,13 +105,14 @@ required resultset classes. Next, create each of the classes you want to load as specified above: package My::Schema::Result::Album; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; -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 to force columns to use UTF-8 encoding: +Load any additional components you may need with the load_components() method, +and provide component configuration if required. For example, if you want +automatic row ordering: - __PACKAGE__->load_components(qw/ ForceUTF8 Core /); + __PACKAGE__->load_components(qw/ Ordered /); + __PACKAGE__->position_column('rank'); Set the table for your class: @@ -119,7 +120,7 @@ Set the table for your class: Add columns to your class: - __PACKAGE__->add_columns(qw/ albumid artist title /); + __PACKAGE__->add_columns(qw/ albumid artist title rank /); Each column can also be set up with its own accessor, data_type and other pieces of information that it may be useful to have -- just pass C a hash: @@ -145,13 +146,20 @@ of information that it may be useful to have -- just pass C a hash: is_nullable => 0, is_auto_increment => 0, default_value => '', + }, + rank => + { data_type => 'integer', + size => 16, + is_nullable => 0, + is_auto_increment => 0, + default_value => '', } ); DBIx::Class doesn't directly use most of this data yet, but various related modules such as L make use of it. Also it allows you to create your database tables from your Schema, instead of the other way around. -See L for details. +See L for details. See L for more details of the possible column attributes. diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index 04f211b..e2f717f 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -11,7 +11,7 @@ DBIx::Class::PK::Auto - Automatic primary key class =head1 SYNOPSIS -__PACKAGE__->load_components(qw/Core/); +use base 'DBIx::Class::Core'; __PACKAGE__->set_primary_key('id'); =head1 DESCRIPTION @@ -19,8 +19,6 @@ __PACKAGE__->set_primary_key('id'); This class overrides the insert method to get automatically incremented primary keys. - __PACKAGE__->load_components(qw/Core/); - PK::Auto is now part of Core. See L for details of component interactions. diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index b3bb934..6945f48 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -28,9 +28,8 @@ DBIx::Class::ResultSource - Result source object # Create a table based result source, in a result class. package MyDB::Schema::Result::Artist; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('artist'); __PACKAGE__->add_columns(qw/ artistid name /); __PACKAGE__->set_primary_key('artistid'); @@ -40,8 +39,9 @@ DBIx::Class::ResultSource - Result source object # Create a query (view) based result source, in a result class package MyDB::Schema::Result::Year2000CDs; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components('Core'); + __PACKAGE__->load_components('InflateColumn::DateTime'); __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table('year2000cds'); @@ -60,10 +60,10 @@ sources, for example L. Table is the default result source type, so one is created for you when defining a result class as described in the synopsis above. -More specifically, the L component pulls in the -L as a base class, which -defines the L -method. When called, C creates and stores an instance of +More specifically, the L base class pulls in the +L component, which defines +the L method. +When called, C
creates and stores an instance of L. Luckily, to use tables as result sources, you don't need to remember any of this. diff --git a/lib/DBIx/Class/ResultSource/View.pm b/lib/DBIx/Class/ResultSource/View.pm index d992c71..3dde9bd 100644 --- a/lib/DBIx/Class/ResultSource/View.pm +++ b/lib/DBIx/Class/ResultSource/View.pm @@ -19,9 +19,8 @@ DBIx::Class::ResultSource::View - ResultSource object representing a view package MyDB::Schema::Result::Year2000CDs; - use base qw/DBIx::Class/; + use base qw/DBIx::Class::Core/; - __PACKAGE__->load_components('Core'); __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); __PACKAGE__->table('year2000cds'); diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index c905730..4c3a0ad 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -33,8 +33,9 @@ DBIx::Class::Schema - composable schemas __PACKAGE__->load_namespaces(); package Library::Schema::Result::CD; - use base qw/DBIx::Class/; - __PACKAGE__->load_components(qw/Core/); # for example + use base qw/DBIx::Class::Core/; + + __PACKAGE__->load_components(qw/InflateColumn::DateTime/); # for example __PACKAGE__->table('cd'); # Elsewhere in your code: diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index bce2032..e6af6e0 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -1,10 +1,9 @@ package # Hide from PAUSE DBIx::Class::Version::Table; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; use strict; use warnings; -__PACKAGE__->load_components(qw/ Core/); __PACKAGE__->table('dbix_class_schema_versions'); __PACKAGE__->add_columns @@ -31,8 +30,7 @@ __PACKAGE__->set_primary_key('version'); package # Hide from PAUSE DBIx::Class::Version::TableCompat; -use base 'DBIx::Class'; -__PACKAGE__->load_components(qw/ Core/); +use base 'DBIx::Class::Core'; __PACKAGE__->table('SchemaVersions'); __PACKAGE__->add_columns @@ -180,7 +178,7 @@ package DBIx::Class::Schema::Versioned; use strict; use warnings; -use base 'DBIx::Class'; +use base 'DBIx::Class::Schema'; use Carp::Clan qw/^DBIx::Class/; use POSIX 'strftime'; diff --git a/lib/DBIx/Class/Storage/DBI/DB2.pm b/lib/DBIx/Class/Storage/DBI/DB2.pm index b36ab13..3bad8e0 100644 --- a/lib/DBIx/Class/Storage/DBI/DB2.pm +++ b/lib/DBIx/Class/Storage/DBI/DB2.pm @@ -38,7 +38,7 @@ DBIx::Class::Storage::DBI::DB2 - Automatic primary key class for DB2 =head1 SYNOPSIS # In your table classes - __PACKAGE__->load_components(qw/PK::Auto Core/); + use base 'DBIx::Class::Core'; __PACKAGE__->set_primary_key('id'); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/Storage/DBI/ODBC.pm b/lib/DBIx/Class/Storage/DBI/ODBC.pm index d9b810a..2b7790d 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC.pm @@ -36,18 +36,11 @@ sub _dbh_last_insert_id { DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers -=head1 SYNOPSIS - - # In your table classes - __PACKAGE__->load_components(qw/Core/); - - =head1 DESCRIPTION This class simply provides a mechanism for discovering and loading a sub-class for a specific ODBC backend. It should be transparent to the user. - =head1 AUTHORS Marc Mims C<< >> diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm b/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm index 1bed7f5..16be2f8 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm @@ -43,8 +43,8 @@ over ODBC =head1 SYNOPSIS - # In your table classes - __PACKAGE__->load_components(qw/PK::Auto Core/); + # In your result (table) classes + use base 'DBIx::Class::Core'; __PACKAGE__->set_primary_key('id'); diff --git a/lib/DBIx/Class/Storage/DBI/Oracle.pm b/lib/DBIx/Class/Storage/DBI/Oracle.pm index da60a2d..399eb70 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle.pm @@ -30,11 +30,6 @@ sub _rebless { DBIx::Class::Storage::DBI::Oracle - Base class for Oracle driver -=head1 SYNOPSIS - - # In your table classes - __PACKAGE__->load_components(qw/Core/); - =head1 DESCRIPTION This class simply provides a mechanism for discovering and loading a sub-class diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index b1f3ddf..2b62826 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -9,8 +9,8 @@ DBIx::Class::Storage::DBI::Oracle::Generic - Oracle Support for DBIx::Class =head1 SYNOPSIS - # In your table classes - __PACKAGE__->load_components(qw/PK::Auto Core/); + # In your result (table) classes + use base 'DBIx::Class::Core'; __PACKAGE__->add_columns({ id => { sequence => 'mysequence', auto_nextval => 1 } }); __PACKAGE__->set_primary_key('id'); __PACKAGE__->sequence('mysequence'); diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index d0e8d73..6636201 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -189,8 +189,8 @@ DBIx::Class::Storage::DBI::Pg - Automatic primary key class for PostgreSQL =head1 SYNOPSIS - # In your table classes - __PACKAGE__->load_components(qw/PK::Auto Core/); + # In your result (table) classes + use base 'DBIx::Class::Core'; __PACKAGE__->set_primary_key('id'); __PACKAGE__->sequence('mysequence'); diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index c119f4e..95122b1 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -74,7 +74,7 @@ DBIx::Class::Storage::DBI::SQLite - Automatic primary key class for SQLite =head1 SYNOPSIS # In your table classes - __PACKAGE__->load_components(qw/PK::Auto Core/); + use base 'DBIx::Class::Core'; __PACKAGE__->set_primary_key('id'); =head1 DESCRIPTION diff --git a/lib/DBIx/Class/UTF8Columns.pm b/lib/DBIx/Class/UTF8Columns.pm index cc18743..b40f676 100644 --- a/lib/DBIx/Class/UTF8Columns.pm +++ b/lib/DBIx/Class/UTF8Columns.pm @@ -23,7 +23,9 @@ DBIx::Class::UTF8Columns - Force UTF8 (Unicode) flag on columns =head1 SYNOPSIS package Artist; - __PACKAGE__->load_components(qw/UTF8Columns Core/); + use base 'DBIx::Class::Core'; + + __PACKAGE__->load_components(qw/UTF8Columns/); __PACKAGE__->utf8_columns(qw/name description/); # then belows return strings with utf8 flag diff --git a/t/20setuperrors.t b/t/20setuperrors.t index 5144f56..25e8f32 100644 --- a/t/20setuperrors.t +++ b/t/20setuperrors.t @@ -1,15 +1,19 @@ -#!/usr/bin/perl +use warnings; +use strict; -use Test::More tests => 1; +use Test::More; +use Test::Exception; -eval { - package BuggyTable; - use base 'DBIx::Class'; +throws_ok ( + sub { + package BuggyTable; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components qw/Core/; - __PACKAGE__->table('buggy_table'); - __PACKAGE__->columns qw/this doesnt work as expected/; -}; + __PACKAGE__->table('buggy_table'); + __PACKAGE__->columns qw/this doesnt work as expected/; + }, + qr/\bcolumns\(\) is a read-only/, + 'columns() error when apparently misused', +); -like($@,qr/\bcolumns\(\) is a read-only/, - "columns() error when apparently misused"); +done_testing; diff --git a/t/72pg.t b/t/72pg.t index 3fdefb7..5a4d162 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -126,9 +126,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('dbic_t_schema.array_test'); __PACKAGE__->add_columns(qw/id arrayfield/); __PACKAGE__->column_info_from_storage(1); @@ -173,9 +172,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('dbic_t_schema.casecheck'); __PACKAGE__->add_columns(qw/id name NAME uc_name/); __PACKAGE__->column_info_from_storage(1); @@ -455,9 +453,8 @@ BEGIN { use strict; use warnings; - use base 'DBIx::Class'; + use base 'DBIx::Class::Core'; - __PACKAGE__->load_components(qw/Core/); __PACKAGE__->table('apk'); @eapk_id_columns = qw( id1 id2 id3 id4 ); diff --git a/t/lib/DBICNSTest/Bogus/A.pm b/t/lib/DBICNSTest/Bogus/A.pm index b525df5..3d2c9ae 100644 --- a/t/lib/DBICNSTest/Bogus/A.pm +++ b/t/lib/DBICNSTest/Bogus/A.pm @@ -1,6 +1,5 @@ package DBICNSTest::Bogus::A; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('a'); __PACKAGE__->add_columns('a'); 1; diff --git a/t/lib/DBICNSTest/Bogus/B.pm b/t/lib/DBICNSTest/Bogus/B.pm index e9cdc37..6cdaaa6 100644 --- a/t/lib/DBICNSTest/Bogus/B.pm +++ b/t/lib/DBICNSTest/Bogus/B.pm @@ -1,6 +1,5 @@ package DBICNSTest::Result::B; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('b'); __PACKAGE__->add_columns('b'); 1; diff --git a/t/lib/DBICNSTest/OtherRslt/D.pm b/t/lib/DBICNSTest/OtherRslt/D.pm index 9a9aaf5..d74ff11 100644 --- a/t/lib/DBICNSTest/OtherRslt/D.pm +++ b/t/lib/DBICNSTest/OtherRslt/D.pm @@ -1,6 +1,5 @@ package DBICNSTest::OtherRslt::D; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('d'); __PACKAGE__->add_columns('d'); 1; diff --git a/t/lib/DBICNSTest/Result/A.pm b/t/lib/DBICNSTest/Result/A.pm index d2faecb..7861989 100644 --- a/t/lib/DBICNSTest/Result/A.pm +++ b/t/lib/DBICNSTest/Result/A.pm @@ -1,6 +1,5 @@ package DBICNSTest::Result::A; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('a'); __PACKAGE__->add_columns('a'); 1; diff --git a/t/lib/DBICNSTest/Result/B.pm b/t/lib/DBICNSTest/Result/B.pm index e9cdc37..6cdaaa6 100644 --- a/t/lib/DBICNSTest/Result/B.pm +++ b/t/lib/DBICNSTest/Result/B.pm @@ -1,6 +1,5 @@ package DBICNSTest::Result::B; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('b'); __PACKAGE__->add_columns('b'); 1; diff --git a/t/lib/DBICNSTest/Rslt/A.pm b/t/lib/DBICNSTest/Rslt/A.pm index 686e329..832500a 100644 --- a/t/lib/DBICNSTest/Rslt/A.pm +++ b/t/lib/DBICNSTest/Rslt/A.pm @@ -1,6 +1,5 @@ package DBICNSTest::Rslt::A; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('a'); __PACKAGE__->add_columns('a'); 1; diff --git a/t/lib/DBICNSTest/Rslt/B.pm b/t/lib/DBICNSTest/Rslt/B.pm index fb02f3f..f7660b9 100644 --- a/t/lib/DBICNSTest/Rslt/B.pm +++ b/t/lib/DBICNSTest/Rslt/B.pm @@ -1,6 +1,5 @@ package DBICNSTest::Rslt::B; -use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/PK::Auto Core/); +use base qw/DBIx::Class::Core/; __PACKAGE__->table('b'); __PACKAGE__->add_columns('b'); 1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm b/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm index 11f10e9..4c98495 100644 --- a/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm +++ b/t/lib/DBICNSTest/RtBug41083/Schema/Foo.pm @@ -1,8 +1,7 @@ package DBICNSTest::RtBug41083::Schema::Foo; use strict; use warnings; -use base 'DBIx::Class'; -__PACKAGE__->load_components('Core'); +use base 'DBIx::Class::Core'; __PACKAGE__->table('foo'); __PACKAGE__->add_columns('foo'); 1; diff --git a/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm b/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm index ca626d7..6a3995f 100644 --- a/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm +++ b/t/lib/DBICNSTest/RtBug41083/Schema_A/A.pm @@ -1,8 +1,7 @@ package DBICNSTest::RtBug41083::Schema_A::A; use strict; use warnings; -use base 'DBIx::Class'; -__PACKAGE__->load_components('Core'); +use base 'DBIx::Class::Core'; __PACKAGE__->table('a'); __PACKAGE__->add_columns('a'); 1; diff --git a/t/lib/DBICTest/BaseResult.pm b/t/lib/DBICTest/BaseResult.pm index 78de2a1..4f38202 100644 --- a/t/lib/DBICTest/BaseResult.pm +++ b/t/lib/DBICTest/BaseResult.pm @@ -4,10 +4,9 @@ package #hide from pause use strict; use warnings; -use base qw/DBIx::Class/; +use base qw/DBIx::Class::Core/; use DBICTest::BaseResultSet; -__PACKAGE__->load_components (qw/Core/); __PACKAGE__->table ('bogus'); __PACKAGE__->resultset_class ('DBICTest::BaseResultSet'); diff --git a/t/lib/DBICTest/ResultSetManager/Foo.pm b/t/lib/DBICTest/ResultSetManager/Foo.pm index 7253ac1..30c1c95 100644 --- a/t/lib/DBICTest/ResultSetManager/Foo.pm +++ b/t/lib/DBICTest/ResultSetManager/Foo.pm @@ -1,8 +1,8 @@ package # hide from PAUSE DBICTest::ResultSetManager::Foo; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; -__PACKAGE__->load_components(qw/ ResultSetManager Core /); +__PACKAGE__->load_components(qw/ ResultSetManager /); __PACKAGE__->table('foo'); sub bar : ResultSet { 'good' } diff --git a/t/lib/DBICVersionNew.pm b/t/lib/DBICVersionNew.pm index 2f6595c..b6508ca 100644 --- a/t/lib/DBICVersionNew.pm +++ b/t/lib/DBICVersionNew.pm @@ -1,10 +1,9 @@ package DBICVersion::Table; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; use strict; use warnings; -__PACKAGE__->load_components(qw/ Core/); __PACKAGE__->table('TestVersion'); __PACKAGE__->add_columns diff --git a/t/lib/DBICVersionOrig.pm b/t/lib/DBICVersionOrig.pm index 5a12ce4..3bdc0e2 100644 --- a/t/lib/DBICVersionOrig.pm +++ b/t/lib/DBICVersionOrig.pm @@ -1,10 +1,9 @@ package DBICVersion::Table; -use base 'DBIx::Class'; +use base 'DBIx::Class::Core'; use strict; use warnings; -__PACKAGE__->load_components(qw/ Core/); __PACKAGE__->table('TestVersion'); __PACKAGE__->add_columns