=cut
-{
- my $warn;
-
- sub compose_connection {
- my ($self, $target, @info) = @_;
-
- carp "compose_connection deprecated as of 0.08000"
- unless ($INC{"DBIx/Class/CDBICompat.pm"} || $warn++);
+sub compose_connection {
+ my ($self, $target, @info) = @_;
- my $base = 'DBIx::Class::ResultSetProxy';
- try {
- eval "require ${base};"
- }
- catch {
- $self->throw_exception
- ("No arguments to load_classes and couldn't load ${base} ($_)")
- };
-
- if ($self eq $target) {
- # Pathological case, largely caused by the docs on early C::M::DBIC::Plain
- foreach my $moniker ($self->sources) {
- my $source = $self->source($moniker);
- my $class = $source->result_class;
- $self->inject_base($class, $base);
- $class->mk_classdata(resultset_instance => $source->resultset);
- $class->mk_classdata(class_resolver => $self);
- }
- $self->connection(@info);
- return $self;
- }
+ carp_once "compose_connection deprecated as of 0.08000"
+ unless $INC{"DBIx/Class/CDBICompat.pm"};
- my $schema = $self->compose_namespace($target, $base);
- {
- no strict 'refs';
- my $name = join '::', $target, 'schema';
- *$name = subname $name, sub { $schema };
- }
+ my $base = 'DBIx::Class::ResultSetProxy';
+ try {
+ eval "require ${base};"
+ }
+ catch {
+ $self->throw_exception
+ ("No arguments to load_classes and couldn't load ${base} ($_)")
+ };
- $schema->connection(@info);
- foreach my $moniker ($schema->sources) {
- my $source = $schema->source($moniker);
+ if ($self eq $target) {
+ # Pathological case, largely caused by the docs on early C::M::DBIC::Plain
+ foreach my $moniker ($self->sources) {
+ my $source = $self->source($moniker);
my $class = $source->result_class;
- #warn "$moniker $class $source ".$source->storage;
- $class->mk_classdata(result_source_instance => $source);
+ $self->inject_base($class, $base);
$class->mk_classdata(resultset_instance => $source->resultset);
- $class->mk_classdata(class_resolver => $schema);
+ $class->mk_classdata(class_resolver => $self);
}
- return $schema;
+ $self->connection(@info);
+ return $self;
+ }
+
+ my $schema = $self->compose_namespace($target, $base);
+ {
+ no strict 'refs';
+ my $name = join '::', $target, 'schema';
+ *$name = subname $name, sub { $schema };
}
+
+ $schema->connection(@info);
+ foreach my $moniker ($schema->sources) {
+ my $source = $schema->source($moniker);
+ my $class = $source->result_class;
+ #warn "$moniker $class $source ".$source->storage;
+ $class->mk_classdata(result_source_instance => $source);
+ $class->mk_classdata(resultset_instance => $source->resultset);
+ $class->mk_classdata(class_resolver => $schema);
+ }
+ return $schema;
}
1;
+++ /dev/null
-package # hide from PAUSE
- DBICTest::Plain;
-
-use strict;
-use warnings;
-use base qw/DBIx::Class::Schema/;
-use DBI;
-
-my $db_file = "t/var/Plain.db";
-
-unlink($db_file) if -e $db_file;
-unlink($db_file . "-journal") if -e $db_file . "-journal";
-mkdir("t/var") unless -d "t/var";
-
-my $dsn = "dbi:SQLite:${db_file}";
-
-__PACKAGE__->load_classes("Test");
-my $schema = __PACKAGE__->compose_connection(
- __PACKAGE__,
- $dsn,
- undef,
- undef,
- { AutoCommit => 1 }
-);
-
-my $dbh = DBI->connect($dsn);
-
-my $sql = <<EOSQL;
-CREATE TABLE test (
- id INTEGER NOT NULL,
- name VARCHAR(32) NOT NULL
-);
-
-INSERT INTO test (id, name) VALUES (1, 'DBIC::Plain is broken!');
-
-EOSQL
-
-$dbh->do($_) for split(/\n\n/, $sql);
-
-1;