X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/da364d0f6dd660d289f890c1423b0c0dd51f690c..88dea78ecdb77761f71c5016ca97e53b2d55d9d3:/SL/DBUtils.pm diff --git a/SL/DBUtils.pm b/SL/DBUtils.pm index 8e1ad458a..e8cd304ee 100644 --- a/SL/DBUtils.pm +++ b/SL/DBUtils.pm @@ -1,5 +1,7 @@ package SL::DBUtils; +use SL::Util qw(trim); + require Exporter; our @ISA = qw(Exporter); @@ -30,7 +32,9 @@ sub conv_b { sub conv_date { my ($value) = @_; - return (defined($value) && "$value" ne "") ? $value : undef; + return undef if !defined $value; + $value = trim($value); + return $value eq "" ? undef : $value; } sub conv_dateq { @@ -222,11 +226,11 @@ sub selectall_as_map { my %hash; if ('' eq ref $value_col) { while (my $ref = $sth->fetchrow_hashref()) { - $hash{$ref->{$key_col}} = $ref->{$value_col}; + $hash{$ref->{$key_col} // ''} = $ref->{$value_col}; } } else { while (my $ref = $sth->fetchrow_hashref()) { - $hash{$ref->{$key_col}} = { map { $_ => $ref->{$_} } @{ $value_col } }; + $hash{$ref->{$key_col} // ''} = { map { $_ => $ref->{$_} } @{ $value_col } }; } }