From 1df47e7452f84e2d8d6673a310aa5cad80b6ca3b Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Fri, 21 May 2010 15:52:42 +0000
Subject: [PATCH] remove errant tsearch joiners if the normalizers are messy
 and leave leading/trailing spaces

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16474 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
index 062ae64c8e..c05d7afbd0 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
@@ -778,7 +778,7 @@ sub buildSQL {
     my $suffix_op = ":$suffix" if $suffix;
     my $suffix_after = "|| '$suffix_op'" if $suffix;
 
-    $sql = "to_tsquery('$classname', $prefix '(' || regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g') $suffix_after || ')')";
+    $sql = "to_tsquery('$classname', $prefix '(' || btrim(regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g'),'&|') $suffix_after || ')')";
 
     return $self->sql($sql);
 }
-- 
2.11.0