allow empty string as a default value

This commit is contained in:
Isaac Connor 2020-10-22 11:26:34 -04:00
parent 40c57b4b23
commit a0f733615c
1 changed files with 2 additions and 2 deletions

View File

@ -395,8 +395,8 @@ sub set {
if ( ( ! exists $$self{$field} ) or (!defined $$self{$field}) or ( $$self{$field} eq '' ) ) { if ( ( ! exists $$self{$field} ) or (!defined $$self{$field}) or ( $$self{$field} eq '' ) ) {
$log->debug("Setting default ($field) (".def_or_undef($$self{$field}).') ('.def_or_undef($defaults{$field}).') ') if $debug; $log->debug("Setting default ($field) (".def_or_undef($$self{$field}).') ('.def_or_undef($defaults{$field}).') ') if $debug;
if ( defined $defaults{$field} ) { if ( defined $defaults{$field} ) {
if ( $defaults{$field} eq 'NOW()' ) { if ( $defaults{$field} eq '' or $defaults{$field} eq 'NOW()' ) {
$$self{$field} = 'NOW()'; $$self{$field} = $defaults{$field};
} else { } else {
$$self{$field} = eval($defaults{$field}); $$self{$field} = eval($defaults{$field});
$log->error( "Eval error of object default $field default ($defaults{$field}) Reason: " . $@ ) if $@; $log->error( "Eval error of object default $field default ($defaults{$field}) Reason: " . $@ ) if $@;