Merge branch 'requirement-specs-custom-variables'
[kivitendo-erp.git] / SL / DB / Helper / CustomVariables.pm
index 55ff121..97837a2 100644 (file)
@@ -295,7 +295,6 @@ sub make_cvar_custom_filter {
       my $conversion  = $config->type =~ m{^(?:date|timestamp)$}       ? $config->type
                       : $config->type =~ m{^(?:customer|vendor|part)$} ? 'integer'
                       : $config->type eq 'number'                      ? 'numeric'
-                      # : $config->type eq 'bool'                        ? 'boolean'
                       :                                                  '';
 
       ($query{config}, $bind_vals{config}) = Rose::DB::Object::QueryBuilder::build_select(
@@ -310,7 +309,7 @@ sub make_cvar_custom_filter {
         query_is_sql       => 1,
       );
 
-      $query{config} =~ s{ \bdefault_value\b \s*=\s* (?!'') }{default_value::${conversion} = }x if $conversion;
+      $query{config} =~ s{ (?<! NOT\( ) default_value (?! \s*is\s+not\s+null) }{default_value::${conversion}}x if $conversion;
 
       ($query{not_customized}, $bind_vals{not_customized}) = Rose::DB::Object::QueryBuilder::build_select(
         dbh          => $config->dbh,
@@ -329,7 +328,7 @@ sub make_cvar_custom_filter {
         $query{$key} =~ s{\bt\d+(?:\.)?\b}{}g;
 
         # manually inline the values. again, rose doen't know how to handly bind params in subqueries :(
-        $query{$key} =~ s{\?}{ $config->dbh->quote($_) }xe for @{ $bind_vals{$key} };
+        $query{$key} =~ s{\?}{ $config->dbh->quote(shift @{ $bind_vals{$key} }) }xeg;
 
         $query{$key} =~ s{\n}{ }g;
       }