From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Fri, 22 Apr 2011 20:45:46 +0000 (+0000)
Subject: Address LP#730743, errant parens cause pain
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fcc7104b3876982b3795664bf2cb3f6c04c64977;p=evergreen%2Fjoelewis.git

Address LP#730743, errant parens cause pain

Specifically, we prune subplans that contain no nodes (empty parens), and avoid dropping out of the top level query context when we encounter a close-paren.


git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20290 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
index 52a203b0d2..479bd40198 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
@@ -546,7 +546,7 @@ sub decompose {
             warn "Encountered explicit group end\n" if $self->debug;
 
             $_ = $';
-            $remainder = $';
+            $remainder = $struct->top_plan ? '' : $';
 
             $last_type = '';
         } elsif ($self->filter_count && /$filter_re/) { # found a filter
@@ -593,7 +593,7 @@ sub decompose {
             warn "Encountered explicit group start\n" if $self->debug;
 
             my ($substruct, $subremainder) = $self->decompose( $', $current_class, $recursing + 1 );
-            $struct->add_node( $substruct );
+            $struct->add_node( $substruct ) if ($substruct);
             $_ = $subremainder;
 
             $last_type = '';
@@ -685,6 +685,8 @@ sub decompose {
 
     }
 
+    $struct = undef if (scalar(@{$struct->query_nodes}) == 0);
+
     return $struct if !wantarray;
     return ($struct, $remainder);
 }