From: Rafael Kitover Date: Sat, 3 Oct 2009 14:09:45 +0000 (+0000) Subject: fix on_connect_ with coderef connect_info X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b09e9528b306fe3394ad0b588c36ebbc2b89c6fb;p=dbsrgits%2FDBIx-Class-Historic.git fix on_connect_ with coderef connect_info --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 89cf5a3..7ab4561 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -878,13 +878,14 @@ sub _determine_driver { my ($self) = @_; if ((not $self->_driver_determined) && (not $self->{_in_determine_driver})) { - my $started_unconnected = 0; + my $started_connected = 0; local $self->{_in_determine_driver} = 1; if (ref($self) eq __PACKAGE__) { my $driver; if ($self->_dbh) { # we are connected $driver = $self->_dbh->{Driver}{Name}; + $started_connected = 1; } else { # if connect_info is a CODEREF, we have no choice but to connect if (ref $self->_dbi_connect_info->[0] && @@ -896,7 +897,6 @@ sub _determine_driver { # try to use dsn to not require being connected, the driver may still # force a connection in _rebless to determine version ($driver) = $self->_dbi_connect_info->[0] =~ /dbi:([^:]+):/i; - $started_unconnected = 1; } } @@ -913,7 +913,7 @@ sub _determine_driver { $self->_init; # run driver-specific initializations $self->_run_connection_actions - if $started_unconnected && defined $self->_dbh; + if !$started_connected && defined $self->_dbh; } }