Make disused "= any" and "<> any" useful
authorMike Rylander <mrylander@gmail.com>
Fri, 29 Oct 2021 14:26:41 +0000 (10:26 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 24 Mar 2022 19:09:49 +0000 (15:09 -0400)
Allow caller to supply a PG-encoded array string to test against a column value.

Also, repair relative week transform that has never worked.

Sponsored-by: C/W MARS
Sponsored-by: Missouri Evergreen Consortium
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Boyer <JBoyer@equinoxOLI.org>
Signed-off-by: rfrasur <rfrasur@library.in.gov>
Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm

index 22bee1a..f805575 100644 (file)
@@ -435,7 +435,7 @@ sub toSQL {
     my $val = $self->{params};
     $val = $$val[0] if (ref($val));
 
-    return "EXTRACT(WEEK FROM \$_$$\$rtime\$_$$\$::TIMESTAMPTZ + \$_$$\$val weeks\$_$$\$)";
+    return "EXTRACT(WEEK FROM \$_$$\$rtime\$_$$\$::TIMESTAMPTZ + \$_$$\$$val weeks\$_$$\$)";
 }
 
 
@@ -947,7 +947,7 @@ sub toSQL {
         } else {
             $sql = '';
         }
-        $sql .= "$val = ANY (".$self->SUPER::toSQL.")";
+        $sql .= "(".$self->SUPER::toSQL.") = ANY ($val)";
 
     } elsif (lc($op) eq '<> any') {
         $val = $$val[0] if (ref($val) eq 'ARRAY');
@@ -957,7 +957,7 @@ sub toSQL {
         } else {
             $sql = '';
         }
-        $sql .= "$val <> ANY (".$self->SUPER::toSQL.")";
+        $sql .= "(".$self->SUPER::toSQL.") <> ANY ($val)";
 
     } elsif (lc($op) eq 'is blank') {
         if ($rel && $rel->is_nullable) { # need to redo this