address the empty-query case
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Apr 2011 21:37:12 +0000 (21:37 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 22 Apr 2011 21:37:12 +0000 (21:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@20297 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/QueryParser.pm

index 2b15e02..c1fb759 100644 (file)
@@ -523,6 +523,13 @@ sub toSQL {
 
     my $core_limit = $self->QueryParser->core_limit || 25000;
 
+    my $flat_where = $$flat_plan{where};
+    if ($flat_where eq '()') {
+        $flat_where = '';
+    } else {
+        $flat_where = "AND $flat_where";
+    }
+
     my $sql = <<SQL;
 SELECT  $key AS id,
         ARRAY_ACCUM(DISTINCT m.source) AS records,
@@ -544,7 +551,7 @@ SELECT  $key AS id,
         $lit_form
         $language
         $bib_level
-        AND $$flat_plan{where}
+        $flat_where
   GROUP BY 1
   ORDER BY 4 $desc NULLS LAST, 5 DESC NULLS LAST, 3 DESC
   LIMIT $core_limit
index f3ebde3..a7e2eff 100644 (file)
@@ -650,7 +650,7 @@ sub decompose {
 
     }
 
-    $struct = undef if (scalar(@{$struct->query_nodes}) == 0);
+    $struct = undef if (scalar(@{$struct->query_nodes}) == 0 && !$struct->top_plan);
 
     return $struct if !wantarray;
     return ($struct, $remainder);