From 085a54454d13441d48bb47319e9dc96a21ec3c53 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 17 Jan 2020 10:25:19 +0100 Subject: [PATCH] Bug 24443: Consider NULL as 0 for issues in items search In items search, we can filter by items issues count, data coming from items.issues. Most of the time, for an item with no issues this column contains NULL. This enhancement proposes to consider NULL as 0 to allow searching items with no issues. Test plan: 1) Use SQL to count items with items.issues = NULL : select count(*) from items where issues is null; 2) Go to items search 3) Perform search with filter "Checkout count" = 0 4) Check you get the same number of results as SQL query Signed-off-by: Maryse Simard Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 2922249d92bad9a1df4ea95b48a7e28fdc68a315) Signed-off-by: Lucas Gass --- C4/Items.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/C4/Items.pm b/C4/Items.pm index 919a695f95..2eebe80ae6 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2137,6 +2137,9 @@ sub _SearchItems_build_where_fragment { } $column = "ExtractValue($sqlfield, '$xpath')"; } + } elsif ($field eq 'issues') { + # Consider NULL as 0 for issues count + $column = 'COALESCE(issues,0)'; } else { $column = $field; } -- 2.39.5