More generally, the fix avoids a to_tsquery exception in cases
where a search term is normalized away to the empty string.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16939
dcc99617-32d9-48b4-a31d-
7c20da2025e4
my $suffix_op = ":$suffix" if $suffix;
my $suffix_after = "|| '$suffix_op'" if $suffix;
- $sql = "to_tsquery('$classname', $prefix '(' || btrim(regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g'),'&|') $suffix_after || ')')";
+ $sql = "to_tsquery('$classname', COALESCE(NULLIF($prefix '(' || btrim(regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g'),'&|') $suffix_after || ')', '()'), ''))";
return $self->sql($sql);
}