From 1fdd7f4b15d39d0b1dcc91e62b32598cef701b4b 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: Dan Scott --- .../OpenILS/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 e931b1a890..2355c22072 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 @@ -738,18 +738,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}); @@ -798,8 +795,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.11.0