Test that ::parent keeps the dbh alive for the child.

This commit is contained in:
Daniel Nichter
2013-02-26 16:34:48 -07:00
parent abcfd2c43f
commit a21c36ac99
2 changed files with 66 additions and 6 deletions

View File

@@ -135,9 +135,10 @@ sub connect {
},
);
}
PTDEBUG && _d($dbh, 'Connected dbh to', $self->{name});
return $self->set_dbh($dbh);
$dbh = $self->set_dbh($dbh);
PTDEBUG && _d($dbh, 'Connected dbh to', $self->{hostname},$self->{dsn_name});
return $dbh;
}
sub set_dbh {
@@ -219,14 +220,17 @@ sub name {
sub DESTROY {
my ($self) = @_;
PTDEBUG && _d('Destroying cxn');
if ( $self->{parent} ) {
PTDEBUG && _d('Not disconnecting dbh in parent');
PTDEBUG && _d($self->{dbh}, 'Not disconnecting dbh in parent');
}
elsif ( $self->{dbh}
&& blessed($self->{dbh})
&& $self->{dbh}->can("disconnect") )
{
PTDEBUG && _d('Disconnecting dbh', $self->{dbh}, $self->{name});
PTDEBUG && _d($self->{dbh}, 'Disconnecting dbh on', $self->{hostname},
$self->{dsn_name});
$self->{dbh}->disconnect();
}