From 05047096df7e18aad6331c61e705499c2820ddde Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 27 Mar 2014 17:10:37 +0100 Subject: [PATCH] =?utf8?q?ParseFilter:=20splitting=20von=20:multi=20=C3=BC?= =?utf8?q?ber=20Text::ParseWords?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Helper/ParseFilter.pm | 3 ++- t/controllers/helpers/parse_filter.t | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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'; -- 2.20.1