LP#118066: fix searches that failed because punctuation was a token in query
authorGalen Charlton <gmc@esilibrary.com>
Tue, 14 May 2013 19:33:54 +0000 (15:33 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 14 May 2013 20:01:51 +0000 (16:01 -0400)
When building the text array literal to pass to evergreen.rel_bump,
make sure that tokens that get {search_}normalize{d} away
don't result in syntax errors.

With this patch, searches like the following will work again:

keyword:Take me to the river / Al Green and Mabon

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index c202dac..4fcbe5e 100644 (file)
@@ -904,9 +904,9 @@ sub flatten {
 
                 if(scalar @bumps > 0 && scalar @{$node->only_positive_atoms} > 0) {
                     # Note: Previous rank function used search_normalize outright. Duplicating that here.
-                    $node_rank .= "\n" . ${spc} x 5 . "* evergreen.rel_bump(('{' || search_normalize(";
-                    $node_rank .= join(") || ',' || search_normalize(",map { $self->QueryParser->quote_phrase_value($_->content) } @{$node->only_positive_atoms});
-                    $node_rank .= ") || '}')::TEXT[], " . $node->table_alias . ".value, '{" . join(",",@bumps) . "}'::TEXT[], '{" . join(",",@bumpmults) . "}'::NUMERIC[])";
+                    $node_rank .= "\n" . ${spc} x 5 . "* evergreen.rel_bump(('{' || quote_literal(search_normalize(";
+                    $node_rank .= join(")) || ',' || quote_literal(search_normalize(",map { $self->QueryParser->quote_phrase_value($_->content) } @{$node->only_positive_atoms});
+                    $node_rank .= ")) || '}')::TEXT[], " . $node->table_alias . ".value, '{" . join(",",@bumps) . "}'::TEXT[], '{" . join(",",@bumpmults) . "}'::NUMERIC[])";
                 }
 
                 my $NOT = '';