Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / SL / Controller / Helper / ParseFilter.pm
index ac086f5..3bf1b65 100644 (file)
@@ -20,11 +20,13 @@ my %filters = (
 );
 
 my %methods = (
-  lt     => sub { +{ lt    => $_[0] } },
-  gt     => sub { +{ gt    => $_[0] } },
-  ilike  => sub { +{ ilike => $_[0] } },
-  like   => sub { +{ like  => $_[0] } },
   enable => sub { ;;;; },
+  map {
+    # since $_ is an alias it can't be used in a closure. even "".$_ or "$_"
+    # does not work, we need a real copy.
+    my $_copy = "$_";
+    $_   => sub { +{ $_copy    => $_[0] } },
+  } qw(similar match imatch regex regexp like ilike rlike is is_not ne eq lt gt le ge),
 );
 
 sub parse_filter {
@@ -74,7 +76,7 @@ sub _pre_parse {
     if ('HASH' eq ref $value) {
       my ($query, $more_objects) = _pre_parse($value, $with_objects, _prefix($prefix, $key));
       push @result,        @$query if $query;
-      push @$with_objects, $key, ($more_objects ? @$more_objects : ());
+      push @$with_objects, _prefix($prefix, $key), ($more_objects ? @$more_objects : ());
     } else {
       push @result, _prefix($prefix, $key) => $value;
     }