From c51601f019f963dcdc875469514aa40802b5c574 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 19 Jun 2015 17:17:14 +0200 Subject: [PATCH] DB-Handle Caches: DATESTYLE korrekt setzen --- SL/DBConnect.pm | 12 +++++++----- SL/DBConnect/Cache.pm | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) 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; -- 2.20.1