dsn => "dbi:mysql:dbname",
user => "root",
password => "",
- namespace => "My",
additional_classes => [qw/DBIx::Class::Foo/],
additional_base_classes => [qw/My::Stuff/],
left_base_classes => [qw/DBIx::Class::Bar/],
die qq/dsn argument is required/ if ! $args{dsn};
- $args{namespace} ||= $class;
- $args{namespace} =~ s/(.*)::$/$1/;
-
my $dsn = $args{dsn};
my ($driver) = $dsn =~ m/^dbi:(\w*?)(?:\((.*?)\))?:/i;
$driver = 'SQLite' if $driver eq 'SQLite2';
DBI Data Source Name.
-=head3 namespace
-
-Namespace under which your table classes will be initialized.
-
=head3 password
Password.
$class->loader_data({
_datasource =>
[ $args{dsn}, $args{user}, $args{password}, $args{options} ],
- _namespace => $args{namespace},
_additional => $additional,
_additional_base => $additional_base,
_left_base => $left_base,
sub _load_classes {
my $class = shift;
- my $namespace = $class->loader_data->{_namespace};
-
my @tables = $class->_tables();
my @db_classes = $class->_db_classes();
my $additional = join '', map "use $_;\n", @{ $class->loader_data->{_additional} };
}
my $table_subclass = $class->_table2subclass($db_schema, $tbl);
- my $table_class = "$namespace\::$table_subclass";
+ my $table_class = "$class\::$table_subclass";
$class->inject_base( $table_class, 'DBIx::Class::Core' );
$_->require for @db_classes;
$self->create();
- my $namespace = 'DBIXCSL_Test_' . $self->{vendor};
+ my $schema_class = 'DBIXCSL_Test_' . $self->{vendor} . '::Schema';
my $debug = ($self->{verbose} > 1) ? 1 : 0;
- my $schema_pkg = "$namespace\::Schema";
-
my %loader_opts = (
dsn => $self->{dsn},
user => $self->{user},
password => $self->{password},
- namespace => $namespace,
constraint => '^(?:\S+\.)?(?i:loader_test)[0-9]+$',
relationships => 1,
debug => $debug,
$loader_opts{drop_db_schema} = $self->{drop_db_schema} if $self->{drop_db_schema};
eval qq{
- package $schema_pkg;
+ package $schema_class;
use base qw/DBIx::Class::Schema::Loader/;
__PACKAGE__->load_from_connection(\%loader_opts);
};
ok(!$@, "Loader initialization failed: $@");
- my $conn = $schema_pkg->connect($self->{dsn},$self->{user},$self->{password});
+ my $conn = $schema_class->connect($self->{dsn},$self->{user},$self->{password});
my $moniker1 = $conn->moniker('loader_test1');
my $rsobj1 = $conn->resultset($moniker1);
# basic rel test
my $obj4 = $rsobj4->find(123);
- isa_ok( $obj4->fkid, "$namespace\::$moniker3");
+ isa_ok( $obj4->fkid, "$schema_class\::$moniker3");
# fk def in comments should not be parsed
my $obj5 = $rsobj5->find( id1 => 1, id2 => 1 );
# mulit-col fk def (works for some, not others...)
my $obj6 = $rsobj6->find(1);
- isa_ok( $obj6->loader_test2, "$namespace\::$moniker2" );
+ isa_ok( $obj6->loader_test2, "$schema_class\::$moniker2" );
SKIP: {
skip "Multi-column FKs are only half-working for this vendor", 1
unless $self->{multi_fk_broken};
# fk that references a non-pk key (UNIQUE)
my $obj8 = $rsobj8->find(1);
- isa_ok( $obj8->loader_test7, "$namespace\::$moniker7" );
+ isa_ok( $obj8->loader_test7, "$schema_class\::$moniker7" );
# from Chisel's tests...
SKIP: {
'One $rsobj10 returned from search' );
my $obj10_3 = $results->first();
- isa_ok( $obj10_3, "$namespace\::$moniker10" );
+ isa_ok( $obj10_3, "$schema_class\::$moniker10" );
is( $obj10_3->loader_test11()->id(), $obj11->id(),
'found same $rsobj11 object we expected' );
}