Call on_connect AFTER actual connection, so we have the correct sqlt_type
Jess Robinson [Mon, 22 May 2006 08:45:35 +0000 (08:45 +0000)]
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm

index 8297e3f..e8a0ea6 100644 (file)
@@ -460,7 +460,7 @@ sub connection {
   my $storage = $storage_class->new;
   $storage->connect_info(\@info);
   $self->storage($storage);
-  $self->on_connect() if($self->can('on_connect'));
+  $self->storage->on_connect(sub { $self->on_connect() } )if($self->can('on_connect'));
   return $self;
 }
 
index 31b3ed8..c676254 100644 (file)
@@ -243,7 +243,7 @@ __PACKAGE__->load_components(qw/AccessorGroup/);
 
 __PACKAGE__->mk_group_accessors('simple' =>
   qw/_connect_info _dbh _sql_maker _conn_pid _conn_tid debug debugfh
-     cursor on_connect_do transaction_depth/);
+     cursor on_connect_do on_connect transaction_depth/);
 
 sub new {
   my $new = bless({}, ref $_[0] || $_[0]);
@@ -435,6 +435,7 @@ 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'};