From: Sven Schöling Date: Thu, 27 Mar 2014 16:10:37 +0000 (+0100) Subject: ParseFilter: splitting von :multi über Text::ParseWords X-Git-Tag: release-3.2.0beta~469 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=05047096df7e18aad6331c61e705499c2820ddde;p=kivitendo-erp.git ParseFilter: splitting von :multi über Text::ParseWords --- diff --git a/SL/Controller/Helper/ParseFilter.pm b/SL/Controller/Helper/ParseFilter.pm index 55e65e1b5..308952b63 100644 --- a/SL/Controller/Helper/ParseFilter.pm +++ b/SL/Controller/Helper/ParseFilter.pm @@ -10,6 +10,7 @@ use SL::Helper::DateTime; use List::MoreUtils qw(uniq); use SL::MoreCommon qw(listify); use Data::Dumper; +use Text::ParseWords; my %filters = ( date => sub { DateTime->from_lxoffice($_[0]) }, @@ -106,7 +107,7 @@ sub _parse_filter { if ($key =~ s/:multi//) { my @multi; my $orig_key = $key; - for my $value (split / /, $value) { + for my $value (parse_line('\s+', 0, $value)) { ($key, $value) = _apply_all($key, $value, qr/\b:(\w+)/, { %filters, %{ $params{filters} || {} } }); ($key, $value) = _apply_all($key, $value, qr/\b::(\w+)/, { %methods, %{ $params{methods} || {} } }); ($key, $value) = _dispatch_custom_filters($params{class}, $with_objects, $key, $value) if $params{class}; diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 21dbb7442..051134660 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -1,6 +1,6 @@ use lib 't'; -use Test::More tests => 30; +use Test::More tests => 31; use Test::Deep; use Data::Dumper; @@ -322,3 +322,15 @@ test { ] ], }, 'complex :multi with custom dispatch and prefix', class => 'SL::DB::Manager::OrderItem'; + +test { + 'description:substr:multi::ilike' => q|term1 "term2 and half" 'term3 and stuff'|, +}, { + query => [ + and => [ + description => { ilike => '%term1%' }, + description => { ilike => '%term2 and half%' }, + description => { ilike => '%term3 and stuff%' }, + ] + ] +}, ':multi with complex tokenizing';