[Bast-commits] r4250 - in
branches/DBIx-Class-Schema-Loader/current: .
lib/DBIx/Class/Schema lib/DBIx/Class/Schema/Loader t t/lib
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Tue Apr 1 16:34:44 BST 2008
Author: ilmari
Date: 2008-04-01 16:34:44 +0100 (Tue, 01 Apr 2008)
New Revision: 4250
Added:
branches/DBIx-Class-Schema-Loader/current/t/24loader_subclass.t
branches/DBIx-Class-Schema-Loader/current/t/lib/TestLoaderSubclass.pm
Modified:
branches/DBIx-Class-Schema-Loader/current/Changes
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm
branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm
Log:
Allow specifying a custom loader_class in loader_options
Modified: branches/DBIx-Class-Schema-Loader/current/Changes
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/Changes 2008-04-01 14:10:31 UTC (rev 4249)
+++ branches/DBIx-Class-Schema-Loader/current/Changes 2008-04-01 15:34:44 UTC (rev 4250)
@@ -3,6 +3,7 @@
Not yet released
- Fix limiting table list to the specified schema for DB2
- Default db_schema to the username for DB2
+ - Allow specifying a custom loader_class in loader_options
0.04999_04 Wed Mar 12, 2008
- Add is_auto_increment detecton for DB2
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm 2008-04-01 14:10:31 UTC (rev 4249)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/Base.pm 2008-04-01 15:34:44 UTC (rev 4250)
@@ -64,6 +64,13 @@
These constructor options are the base options for
L<DBIx::Class::Schema::Loader/loader_opts>. Available constructor options are:
+=head2 loader_class
+
+Use the specified class as the loader instead of
+C<DBIx::Class::Schema::Loader${storage_type}>. This is mostly useful for
+subclassing existing loaders or in conjunction with
+L<DBIx::Class::Schema::Loader/dump_to_dir>.
+
=head2 skip_relationships
Skip setting up relationships. The default is to attempt the loading
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm 2008-04-01 14:10:31 UTC (rev 4249)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader/DBI.pm 2008-04-01 15:34:44 UTC (rev 4250)
@@ -45,7 +45,7 @@
croak "Failed to require $subclass: $@";
}
elsif(!$@) {
- bless $self, "DBIx::Class::Schema::Loader::DBI::${driver}";
+ bless $self, $subclass unless $self->isa($subclass);
}
# Set up the default quoting character and name seperators
Modified: branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm 2008-04-01 14:10:31 UTC (rev 4249)
+++ branches/DBIx-Class-Schema-Loader/current/lib/DBIx/Class/Schema/Loader.pm 2008-04-01 15:34:44 UTC (rev 4250)
@@ -106,7 +106,8 @@
$args->{dump_directory} ||= $self->dump_to_dir;
# XXX this only works for relative storage_type, like ::DBI ...
- my $impl = "DBIx::Class::Schema::Loader" . $self->storage_type;
+ my $impl = $args->{loader_class}
+ || "DBIx::Class::Schema::Loader" . $self->storage_type;
$impl->require or
croak qq/Could not load storage_type loader "$impl": / .
qq/"$UNIVERSAL::require::ERROR"/;
Added: branches/DBIx-Class-Schema-Loader/current/t/24loader_subclass.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/24loader_subclass.t (rev 0)
+++ branches/DBIx-Class-Schema-Loader/current/t/24loader_subclass.t 2008-04-01 15:34:44 UTC (rev 4250)
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+use Test::More;
+use lib qw(t/lib);
+use make_dbictest_db;
+
+{
+ package DBICTest::Schema;
+ use base qw/ DBIx::Class::Schema::Loader /;
+ __PACKAGE__->loader_options( loader_class => 'TestLoaderSubclass' );
+}
+
+plan tests => 2;
+
+my $schema = DBICTest::Schema->connect($make_dbictest_db::dsn);
+isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::SQLite');
+isa_ok($schema->_loader, 'TestLoaderSubclass');
Added: branches/DBIx-Class-Schema-Loader/current/t/lib/TestLoaderSubclass.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/current/t/lib/TestLoaderSubclass.pm (rev 0)
+++ branches/DBIx-Class-Schema-Loader/current/t/lib/TestLoaderSubclass.pm 2008-04-01 15:34:44 UTC (rev 4250)
@@ -0,0 +1,7 @@
+package TestLoaderSubclass;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Schema::Loader::DBI::SQLite/;
+
+1;
More information about the Bast-commits
mailing list