From 2355004e13ab69af36d7be914d9f47028500e05d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 7 Nov 2018 13:43:52 -0300 Subject: [PATCH] Bug 21413: Fix condition to avoid operator bnding isssues 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 --- C4/Items.pm | 2 +- t/db_dependent/Items/GetItemsForInventory.t | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Items.pm b/C4/Items.pm index 09167060a3..cf05a4c207 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -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 ) { diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t index d2bd9f7002..af136dc465 100755 --- a/t/db_dependent/Items/GetItemsForInventory.t +++ b/t/db_dependent/Items/GetItemsForInventory.t @@ -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 } } ); -- 2.19.1