From 3249c78b060fb6bcf00964b825c3a77c332f73a4 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Wed, 10 Oct 2012 17:23:43 -0400 Subject: [PATCH] QueryParser Driver: Remove Unphrases, add negates Signed-off-by: Thomas Berezansky Signed-off-by: Lebbeous Fogle-Weekley --- .../Application/Storage/Driver/Pg/QueryParser.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 16f4731b23..9afb7540ac 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 @@ -929,18 +929,15 @@ sub flatten { } } + my $NOT = ''; + $NOT = 'NOT ' if $node->negate; - $where .= '(' . $talias . ".id IS NOT NULL"; + $where .= "$NOT(" . $talias . ".id IS NOT NULL"; if (@{$node->phrases}) { $where .= ' AND ' . join(' AND ', map { "${talias}.value ~* ".$self->QueryParser->quote_phrase_value($_) } @{$node->phrases}); } - if (@{$node->unphrases}) { - $where .= ' AND ' . join(' AND ', map { - "${talias}.value !~* ".$self->QueryParser->quote_phrase_value($_) - } @{$node->unphrases}); - } for my $atom (@{$node->only_real_atoms}) { next unless $atom->{content} && $atom->{content} =~ /(^\^|\$$)/; $where .= " AND ${talias}.value ~* ".$self->QueryParser->quote_phrase_value($atom->{content}); @@ -989,8 +986,11 @@ sub flatten { push(@rank_list, @{$$subnode{rank_list}}); $from .= $$subnode{from}; + my $NOT = ''; + $NOT = 'NOT ' if $node->negate; + if ($$subnode{where} ne '') { - $where .= "(\n" + $where .= "$NOT(\n" . ${spc} x ($self->plan_level + 6) . $$subnode{where} . "\n" . ${spc} x ($self->plan_level + 5) . ')'; } -- 2.43.2