Prevent uninit var warnings in QueryParser.pm
authorDan Scott <dan@coffeecode.net>
Mon, 13 Jun 2011 13:45:39 +0000 (09:45 -0400)
committerDan Scott <dan@coffeecode.net>
Mon, 13 Jun 2011 13:50:02 +0000 (09:50 -0400)
$suffix_op and $prefix_op would not be defined if $suffix or $prefix did
not evaluate to true, leading to warnings about undefined variables in
open-ils.storage_stderr.log.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index b858fd5..8cd490c 100644 (file)
@@ -834,8 +834,11 @@ sub buildSQL {
     my $suffix = $self->suffix || '';
 
     $prefix = "'$prefix' ||" if $prefix;
-    my $suffix_op = ":$suffix" if $suffix;
-    my $suffix_after = "|| '$suffix_op'" if $suffix;
+    my $suffix_op = '';
+    my $suffix_after = '';
+
+    $suffix_op = ":$suffix" if $suffix;
+    $suffix_after = "|| '$suffix_op'" if $suffix;
 
     $sql = "to_tsquery('$classname', COALESCE(NULLIF($prefix '(' || btrim(regexp_replace($sql,E'(?:\\\\s+|:)','$suffix_op&','g'),'&|') $suffix_after || ')', '()'), ''))";