use connection hack only for schema_base_class
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader.pm
index 78b0507..1c7b649 100644 (file)
@@ -244,10 +244,9 @@ sub connection {
             if $temp_loader->schema_base_class;
 
         $self->load_components(@components);
-    }
 
-    # This hack is necessary if we changed @ISA of $self through ->load_components.
-    {
+        # This hack is necessary because we changed @ISA of $self through
+        # ->load_components.
         no warnings 'redefine';
 
         local *connection = subname __PACKAGE__.'::connection' => sub {
@@ -257,6 +256,9 @@ sub connection {
 
         $self = $self->connection(@_);
     }
+    else {
+        $self = $self->next::method(@_);
+    }
 
     my $class = ref $self || $self;
     if(!$class->_loader_invoked) {