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
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 = '';
}
+ $struct = undef if (scalar(@{$struct->query_nodes}) == 0);
+
return $struct if !wantarray;
return ($struct, $remainder);
}