From: Thomas Berezansky Date: Wed, 10 Oct 2012 21:40:41 +0000 (-0400) Subject: QueryParser Driver: Remove Unphrases, add negates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=513a9cd86e577918e8b71aac360b882c2e312b44;p=working%2FEvergreen.git QueryParser Driver: Remove Unphrases, add negates Signed-off-by: Thomas Berezansky --- 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 7ded478467..cb0fe13b5f 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 @@ -733,10 +733,11 @@ sub flatten { } } + my $NOT = ''; + $NOT = 'NOT ' if $node->negate; - $where .= '(' . $talias . ".id IS NOT NULL"; + $where .= "$NOT(" . $talias . ".id IS NOT NULL"; $where .= ' AND ' . join(' AND ', map {"${talias}.value ~* ".$self->QueryParser->quote_phrase_value($_)} @{$node->phrases}) if (@{$node->phrases}); - $where .= ' AND ' . join(' AND ', map {"${talias}.value !~* ".$self->QueryParser->quote_phrase_value($_)} @{$node->unphrases}) if (@{$node->unphrases}); $where .= ')'; push @rank_list, $node_rank; @@ -766,6 +767,8 @@ sub flatten { } else { my $subnode = $node->flatten; + my $NOT = ''; + $NOT = 'NOT ' if $node->negate; # strip the trailing bool from the previous loop if there is # nothing to add to the where within this loop. if ($$subnode{where} eq '()') { @@ -775,7 +778,7 @@ sub flatten { push(@rank_list, @{$$subnode{rank_list}}); $from .= $$subnode{from}; - $where .= "$$subnode{where}" unless $$subnode{where} eq '()'; + $where .= "$NOT$$subnode{where}" unless $$subnode{where} eq '()'; if ($$subnode{with}) { $with .= ",\n " if $with;