From 0662b43a449f33fbb659b94a222da099d342a19c Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Tue, 18 Sep 2012 11:55:07 -0400 Subject: [PATCH 1/1] QueryParser Driver: Improve format filter Allow multi-select in particular, and make negate more intuitive. -format(at-d) would previously generate: -item_type(a,t) -item_form(d) Now it generates: -(item_type(a,t) item_form(d)) Multi-select allows for things like: format(at-d,g) To generate: ((item_type(a,t) item_form(d)) || item_type(g)) Negating that results in: -((item_type(a,t) item_form(d)) || item_type(g)) Signed-off-by: Thomas Berezansky Signed-off-by: Lebbeous Fogle-Weekley --- .../Storage/Driver/Pg/QueryParser.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index bb12b75804..9fff3de9ee 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -67,13 +67,19 @@ sub format_callback { my $return = ''; my $negate_flag = ($negate ? '-' : ''); - if(@$params[0]) { - my ($t,$f) = split('-', @$params[0]); - $return .= $negate_flag .'item_type(' . join(',',split('', $t)) . ')' if ($t); - $return .= ' ' if ($t and $f); - $return .= $negate_flag .'item_form(' . join(',',split('', $f)) . ')' if ($f); - $return = '(' . $return . ')' if ($t and $f); + my @returns; + for my $param (@$params) { + my ($t,$f) = split('-', $param); + my $treturn = ''; + $treturn .= 'item_type(' . join(',',split('', $t)) . ')' if ($t); + $treturn .= ' ' if ($t and $f); + $treturn .= 'item_form(' . join(',',split('', $f)) . ')' if ($f); + $treturn = '(' . $treturn . ')' if ($t and $f); + push(@returns, $treturn) if $treturn; } + $return = join(' || ', @returns); + $return = '(' . $return . ')' if(@returns > 1); + $return = $negate_flag.$return if($return); return $return; } -- 2.43.2