From: Matt S Trout Date: Fri, 27 Jan 2006 03:14:15 +0000 (+0000) Subject: Hopefully made in-place compose_connection work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=be381829d5053a51dccbec35d95607126667b67c;p=dbsrgits%2FDBIx-Class-Historic.git Hopefully made in-place compose_connection work --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 4ec608d..bfc27cd 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -199,6 +199,7 @@ sub load_classes { die $@ unless $@ =~ /Can't locate/; } $class->register_class($comp => $comp_class); + # if $class->can('result_source_instance'); } } } @@ -231,6 +232,19 @@ sub compose_connection { my ($self, $target, @info) = @_; my $base = 'DBIx::Class::ResultSetProxy'; $base->require; + + 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); + } + return $self; + } + my $schema = $self->compose_namespace($target, $base); $schema->connection(@info); foreach my $moniker ($schema->sources) {