Back to on_connect in connection, rather than populate_dbh, deploy ensures its connected
Jess Robinson [Mon, 22 May 2006 14:52:53 +0000 (14:52 +0000)]
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm

index e8a0ea6..b085504 100644 (file)
@@ -460,7 +460,7 @@ sub connection {
   my $storage = $storage_class->new;
   $storage->connect_info(\@info);
   $self->storage($storage);
-  $self->storage->on_connect(sub { $self->on_connect() } )if($self->can('on_connect'));
+  $self->on_connect() if($self->can('on_connect'));
   return $self;
 }
 
@@ -715,6 +715,7 @@ across all databases, or fully handle complex relationships.
 sub deploy {
   my ($self, $sqltargs) = @_;
   $self->throw_exception("Can't deploy without storage") unless $self->storage;
+  $self->storage->ensure_connected();
   $self->storage->deploy($self, undef, $sqltargs);
 }
 
index c676254..e46a7bd 100644 (file)
@@ -435,7 +435,6 @@ sub _populate_dbh {
   foreach my $sql_statement (@{$self->on_connect_do || []}) {
     $self->_dbh->do($sql_statement);
   }
-  $self->on_connect->();
 
   $self->_conn_pid($$);
   $self->_conn_tid(threads->tid) if $INC{'threads.pm'};