From 3bedfa5f769217009c0083901af420f784b514d0 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Mon, 17 Jan 2022 16:37:49 +0000 Subject: [PATCH] 93_DbRep: contrib 8.47.0 git-svn-id: https://svn.fhem.de/fhem/trunk@25480 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/93_DbRep.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fhem/contrib/DS_Starter/93_DbRep.pm b/fhem/contrib/DS_Starter/93_DbRep.pm index d2167b290..59268a975 100644 --- a/fhem/contrib/DS_Starter/93_DbRep.pm +++ b/fhem/contrib/DS_Starter/93_DbRep.pm @@ -7001,7 +7001,7 @@ sub DbRep_sqlCmdDone { ReadingsBulkUpdateValue ($hash, "sqlCmd", $cmd); ReadingsBulkUpdateValue ($hash, "sqlResultNumRows", $nrows); - DbRep_addSQLcmdCache ($name, $cmd); # Drop-Down Liste bisherige sqlCmd-Befehle füllen und in Key-File sichern + DbRep_addSQLcmdCache ($name); # Drop-Down Liste bisherige sqlCmd-Befehle füllen und in Key-File sichern if ($srf eq "sline") { $rowstring =~ s/§/]|[/g; @@ -11455,12 +11455,9 @@ return; #################################################################################################### sub DbRep_addSQLcmdCache { my $name = shift; - my $cmd = shift; my $hash = $defs{$name}; - $cmd = _DbRep_convertSQL ($cmd); - my $hlc = AttrVal($name, "sqlCmdHistoryLength", 0); # Anzahl der Einträge in Drop-Down Liste my $tmpsql = delete $data{DbRep}{$name}{sqlcache}{temp}; # SQL incl. Formatierung aus Zwischenspeicher @@ -11500,7 +11497,7 @@ sub DbRep_listSQLcmdCache { $cache .= $key." => ".$data{DbRep}{$name}{sqlcache}{cmd}{$key}."\n"; if ($write) { - $cstr .= $key."|=>|"._DbRep_convertSQL ($data{DbRep}{$name}{sqlcache}{cmd}{$key}).","; + $cstr .= $key."|=>|"._DbRep_convertSQL ($data{DbRep}{$name}{sqlcache}{cmd}{$key}, 1).","; } else { $cstr .= _DbRep_convertSQL ($data{DbRep}{$name}{sqlcache}{cmd}{$key}).","; @@ -11547,9 +11544,16 @@ return; #################################################################################################### # SQL Statement konvertieren +# $write - setzen für Schreiben Cache File #################################################################################################### sub _DbRep_convertSQL { - my $cmd = shift; + my $cmd = shift; + my $write = shift // 0; + + if($write) { + $cmd =~ s/\n/*/g; + $cmd =~ s/\s/ /g; + } $cmd =~ s/\s+/ /g; $cmd =~ s/,/,/g; # Forum: https://forum.fhem.de/index.php/topic,103908.0.html @@ -11564,6 +11568,7 @@ return $cmd; sub _DbRep_deconvertSQL { my $cmd = shift; + $cmd =~ s/*/\n/g; $cmd =~ s/ / /g; $cmd =~ s/,/,/g; # Forum: https://forum.fhem.de/index.php/topic,103908.0.html