From 0df4e6c505af74afd8dd0bf89bd5509cace7c7e5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jun 2021 14:54:47 +0200 Subject: [PATCH] Bug 28523: Escape 'rank' in bor_issues_top.pl It's a MySQL 8 keyword Test plan: Turn off strict_sql_modes (there are other problems in this script) Hit Home Reports > Patrons with the most checkouts Submit the form Without this patch you got: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RANK, borrowers.borrowernumber AS ID FROM `old_issues` With this patch applied you see the report result view Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 3a3537fd9333636aa0e52b06447ad3f74798dace) Signed-off-by: Victor Grousset/tuxayo (cherry picked from commit 369c720beb56925871281b4edfd16f81410772cf) Signed-off-by: Victor Grousset/tuxayo (cherry picked from commit 45777508b2ef931724f36d15d996d80844d54737) Signed-off-by: Wainui Witika-Park (cherry picked from commit 45777508b2ef931724f36d15d996d80844d54737) --- reports/bor_issues_top.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl index 45fcb77dce..c0bc0e6736 100755 --- a/reports/bor_issues_top.pl +++ b/reports/bor_issues_top.pl @@ -251,7 +251,7 @@ sub calculate { my $strcalc ; # Processing average loanperiods - $strcalc .= "SELECT CONCAT_WS('', borrowers.surname , \",\\t\", borrowers.firstname), COUNT(*) AS RANK, borrowers.borrowernumber AS ID"; + $strcalc .= "SELECT CONCAT_WS('', borrowers.surname , \",\\t\", borrowers.firstname), COUNT(*) AS `RANK`, borrowers.borrowernumber AS ID"; $strcalc .= " , $colfield " if ($colfield); $strcalc .= " FROM `old_issues` LEFT JOIN borrowers USING(borrowernumber) @@ -276,7 +276,7 @@ sub calculate { } $strcalc .= " GROUP BY borrowers.borrowernumber"; $strcalc .= ", $colfield" if ($column); - $strcalc .= " ORDER BY RANK DESC"; + $strcalc .= " ORDER BY `RANK` DESC"; $strcalc .= ",$colfield " if ($colfield); $strcalc .= " LIMIT $limit" if ($limit); -- 2.39.5