From 8d7f065c03ac9085185fabf582dd74cc35ce9ce8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jun 2021 14:51:08 +0200 Subject: [PATCH] Bug 28524: Escape 'rank' in cat_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 > Most-circulated items 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, biblio.biblionumber AS ID, itemcallnumber as CALLNUM, ccode as CCODE, loca' at line 1 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 ea214856d112e262f2ab7df223b6ab9bf673ee67) Signed-off-by: Victor Grousset/tuxayo (cherry picked from commit f27cfd734b78c947e60e5603f19055a9204b0ba3) Signed-off-by: Victor Grousset/tuxayo --- reports/cat_issues_top.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reports/cat_issues_top.pl b/reports/cat_issues_top.pl index 596ea00449..1de280013a 100755 --- a/reports/cat_issues_top.pl +++ b/reports/cat_issues_top.pl @@ -298,7 +298,7 @@ sub calculate { my $strcalc ; # Processing average loanperiods - $strcalc .= "SELECT DISTINCT biblio.title, COUNT(biblio.biblionumber) AS RANK, biblio.biblionumber AS ID"; + $strcalc .= "SELECT DISTINCT biblio.title, COUNT(biblio.biblionumber) AS `RANK`, biblio.biblionumber AS ID"; $strcalc .= ", itemcallnumber as CALLNUM"; $strcalc .= ", ccode as CCODE"; $strcalc .= ", location as LOC"; @@ -346,7 +346,7 @@ sub calculate { $strcalc .= " group by biblio.biblionumber"; $strcalc .= ", $colfield" if ($column); - $strcalc .= " order by RANK DESC"; + $strcalc .= " order by `RANK` DESC"; $strcalc .= ", $colfield " if ($colfield); my $dbcalc = $dbh->prepare($strcalc); -- 2.39.5