Make nodal groups explicit in canonical QP queries
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Sat, 8 Sep 2012 02:43:17 +0000 (22:43 -0400)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sun, 9 Sep 2012 19:16:08 +0000 (15:16 -0400)
This patch is required to make the current unintuitive grouping
around operators apparent. Without this patch, one test will pass
on master that should not.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm

index 7c66003..c5c8ece 100644 (file)
@@ -915,6 +915,7 @@ sub abstract_query2str_impl {
     $depth |= 0;
 
     my $qpconfig = $parser_config{QueryParser};
+    my $isnode;
 
     my $gs = $qpconfig->{operators}{group_start};
     my $ge = $qpconfig->{operators}{group_end};
@@ -933,6 +934,7 @@ sub abstract_query2str_impl {
             $q .= join(" ", map { _abstract_query2str_modifier($_) } @{$abstract_query->{modifiers}}) if
                 exists $abstract_query->{modifiers};
         } elsif ($abstract_query->{type} eq 'node') {
+            $isnode = 1;
             if ($abstract_query->{alias}) {
                 $q .= " " . $abstract_query->{alias};
                 $q .= "|$_" foreach @{$abstract_query->{alias_fields}};
@@ -972,6 +974,8 @@ sub abstract_query2str_impl {
             } @{$abstract_query->{$op}}
         );
     }
+
+    $q = "($q)" if $isnode;
     $q .= " ";
 
     $q .= $ge if $abstract_query->{type} and $abstract_query->{type} eq "query_plan" and $depth;