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 <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 3a3537fd93)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
(cherry picked from commit 369c720beb)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
(cherry picked from commit 45777508b2)
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit 45777508b2)
This commit is contained in:
Jonathan Druart 2021-06-16 14:54:47 +02:00 committed by Wainui Witika-Park
parent 41f168862a
commit 0df4e6c505
1 changed files with 2 additions and 2 deletions

View File

@ -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);