From: Sven Schöling Date: Fri, 19 Jun 2015 15:17:14 +0000 (+0200) Subject: DB-Handle Caches: DATESTYLE korrekt setzen X-Git-Tag: release-3.3.0beta~38 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c51601f019f963dcdc875469514aa40802b5c574;p=kivitendo-erp.git DB-Handle Caches: DATESTYLE korrekt setzen --- diff --git a/SL/DBConnect.pm b/SL/DBConnect.pm index 369cfe158..4ee48733f 100644 --- a/SL/DBConnect.pm +++ b/SL/DBConnect.pm @@ -33,18 +33,20 @@ sub _connect { sub connect { my ($self, @args) = @_; + my $initial_sql = $self->get_initial_sql; - if (my $cached_dbh = SL::DBConnect::Cache->get(@args)) { + if (my $cached_dbh = SL::DBConnect::Cache->get(@args, $initial_sql)) { return $cached_dbh; } my $dbh = $self->_connect(@args); return undef if !$dbh; - my $initial_sql = $self->get_initial_sql; - $dbh->do($initial_sql) if $initial_sql; - - SL::DBConnect::Cache->store($dbh, @args); + if ($initial_sql) { + $dbh->do($initial_sql); + $dbh->commit if !$dbh->{AutoCommit}; + } + SL::DBConnect::Cache->store($dbh, @args, $initial_sql); return $dbh; } diff --git a/SL/DBConnect/Cache.pm b/SL/DBConnect/Cache.pm index 4f1a465b5..778785ce0 100644 --- a/SL/DBConnect/Cache.pm +++ b/SL/DBConnect/Cache.pm @@ -42,7 +42,7 @@ sub clear { sub _args2str { my (@args) = @_; - my ($dbconnect, $dbuser, $dbpasswd, $options) = @_; + my ($dbconnect, $dbuser, $dbpasswd, $options, $initial_sql) = @_; $dbconnect //= ''; $dbuser //= ''; $dbpasswd //= ''; @@ -52,7 +52,7 @@ sub _args2str { map { $_ => $options->{$_} } sort keys %$options; # deterministic order - join ';', apply { s/([;\\])/\\$1/g } $dbconnect, $dbuser, $dbpasswd, $options_str; + join ';', apply { s/([;\\])/\\$1/g } $dbconnect, $dbuser, $dbpasswd, $options_str, $initial_sql; } 1;