}
}
+ 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;
} 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 '()') {
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;