Bug 21413: Fix condition to avoid operator bnding isssues
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 7 Nov 2018 16:43:52 +0000 (13:43 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 8 Nov 2018 13:32:42 +0000 (13:32 +0000)
The original WHERE condition wasn't enclosed in parenthesis, and hence
was subject to binding precedence issues in some situations.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/Items.pm
t/db_dependent/Items/GetItemsForInventory.t

index 0916706..cf05a4c 100644 (file)
@@ -878,7 +878,7 @@ sub GetItemsForInventory {
 
     if ( $ignore_waiting_holds ) {
         $query .= "LEFT JOIN reserves ON items.itemnumber = reserves.itemnumber ";
-        push( @where_strings, q{reserves.found != 'W' OR reserves.found IS NULL} );
+        push( @where_strings, q{(reserves.found != 'W' OR reserves.found IS NULL)} );
     }
 
     if ( @where_strings ) {
index d2bd9f7..af136dc 100755 (executable)
@@ -87,6 +87,7 @@ subtest 'Skip items with waiting holds' => sub {
                 homebranch       => $library->id,
                 holdingbranch    => $library->id,
                 itype            => $itemtype->itemtype,
+                reserves         => undef
             }
         }
     );
@@ -99,6 +100,7 @@ subtest 'Skip items with waiting holds' => sub {
                 homebranch       => $library->id,
                 holdingbranch    => $library->id,
                 itype            => $itemtype->itemtype,
+                reserves         => undef
             }
         }
     );