X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=7ebea34f821239ea4612302135c2f93008d981d7;hb=afcfff010f5a1d6dbc3a5fb6dfbaeb6246c33372;hp=c3a8e4911760538aaf65a58e21cbdfd6969df245;hpb=5e80aa921a3156eb3e12b5bd02f829563e03dddb;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index c3a8e49..7ebea34 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -563,7 +563,7 @@ sub dbh_do { my $self = shift; my $code = shift; - my $dbh = $self->_dbh; + my $dbh = $self->_get_dbh; return $self->$code($dbh, @_) if $self->{_in_dbh_do} || $self->{transaction_depth}; @@ -574,11 +574,6 @@ sub dbh_do { my $want_array = wantarray; eval { - $self->_verify_pid if $dbh; - if(!$self->_dbh) { - $self->_populate_dbh; - $dbh = $self->_dbh; - } if($want_array) { @result = $self->$code($dbh, @_); @@ -625,8 +620,7 @@ sub txn_do { my $tried = 0; while(1) { eval { - $self->_verify_pid if $self->_dbh; - $self->_populate_dbh if !$self->_dbh; + $self->_get_dbh; $self->txn_begin; if($want_array) { @@ -815,6 +809,7 @@ sub dbh { # this is the internal "get dbh or connect (don't check)" method sub _get_dbh { my $self = shift; + $self->_verify_pid if $self->_dbh; $self->_populate_dbh unless $self->_dbh; return $self->_dbh; } @@ -966,7 +961,7 @@ sub _do_query { my @bind = map { [ undef, $_ ] } @do_args; $self->_query_start($sql, @bind); - $self->_dbh->do($sql, $attrs, @do_args); + $self->_get_dbh->do($sql, $attrs, @do_args); $self->_query_end($sql, @bind); } @@ -1364,6 +1359,7 @@ sub insert_bulk { local $Data::Dumper::Indent = 1; local $Data::Dumper::Useqq = 1; local $Data::Dumper::Quotekeys = 0; + local $Data::Dumper::Sortkeys = 1; $self->throw_exception(sprintf "%s for populate slice:\n%s", $tuple_status->[$i][1], @@ -2492,7 +2488,6 @@ Returns the datetime parser class sub datetime_parser { my $self = shift; return $self->{datetime_parser} ||= do { - $self->_populate_dbh unless $self->_dbh; $self->build_datetime_parser(@_); }; } @@ -2513,10 +2508,14 @@ See L =cut sub build_datetime_parser { + if (not $_[0]->_driver_determined) { + $_[0]->_determine_driver; + goto $_[0]->can('build_datetime_parser'); + } + my $self = shift; my $type = $self->datetime_parser_type(@_); - eval "use ${type}"; - $self->throw_exception("Couldn't load ${type}: $@") if $@; + $self->ensure_class_loaded ($type); return $type; } @@ -2548,10 +2547,12 @@ sub lag_behind_master { sub DESTROY { my $self = shift; + $self->_verify_pid if $self->_dbh; # some databases need this to stop spewing warnings if (my $dbh = $self->_dbh) { + local $@; eval { $dbh->disconnect }; }