From 6d439a5c5852db2c524c5ba027d0ce58c0d8d537 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 Feb 2018 18:08:03 -0300 Subject: [PATCH] Bug 20144: [sql_modes] Remove HAVING clause in GetUpcomingDueIssues More attention needed here! Fix for: Non-grouping field 'days_until_due' is used in HAVING clause t/db_dependent/Circulation.t Signed-off-by: Josef Moravec Signed-off-by: Julian Maurice Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6b4ae913b9..8a97d0074e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2524,12 +2524,15 @@ sub GetUpcomingDueIssues { my $dbh = C4::Context->dbh; my $statement = <= 0 AND days_until_due <= ? +SELECT * +FROM ( + SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail + FROM issues + LEFT JOIN items USING (itemnumber) + LEFT OUTER JOIN branches USING (branchcode) + WHERE returndate is NULL +) tmp +WHERE days_until_due >= 0 AND days_until_due <= ? END_SQL my @bind_parameters = ( $params->{'days_in_advance'} ); -- 2.39.5