Skip to content

Commit 82a6615

Browse files
mdhafenfridobox
authored andcommitted
Bug 28977: Fix cat_issues_top.pl report with strict SQL modes
To get the 'Most circulated items' report to run in ONLY_FULL_GROUP_BY Sql mode. Test plan: Turn on strict_sql_modes ( make sure <strict_sql_modes> is 1 in KOHA_CONF ) Go to Reports -> Most circulated items submit the form. Without the patch you get an error like: CGI::Compile::ROOT::usr_local_koha_master_reports_cat_issues_top_2epl::calculate(): DBI Exception: DBD::mysql::st execute failed: Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'koha_main_v4.items.itemcallnumber' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by [for Statement "SELECT DISTINCT biblio.title, COUNT(biblio.biblionumber) AS `RANK`, biblio.biblionumber AS ID, itemcallnumber as CALLNUM, ccode as CCODE, location as LOC FROM `old_issues` LEFT JOIN items USING(itemnumber) LEFT JOIN biblio USING(biblionumber) LEFT JOIN biblioitems USING(biblionumber) LEFT JOIN borrowers USING(borrowernumber) WHERE 1 AND old_issues.issuedate > '2020-08-03' AND old_issues.issuedate < '2021-05-17' AND old_issues.returndate > '2020-08-27' AND old_issues.returndate < '2021-06-01' AND old_issues.branchcode like '403' AND items.itype like 'F' AND ccode like 'FIC' AND borrowers.categorycode like 'ST' group by biblio.biblionumber order by `RANK` DESC"] at /usr/local/koha_master/reports/cat_issues_top.pl line 67 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 With the patch you will see the report results view. Signed-off-by: David Nind <david@davidnind.com> JD Amended patch - adjust commit's title Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
1 parent 5903ae2 commit 82a6615

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

reports/cat_issues_top.pl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@ sub calculate {
295295
my $strcalc ;
296296

297297
# Processing average loanperiods
298-
$strcalc .= "SELECT DISTINCT biblio.title, COUNT(biblio.biblionumber) AS `RANK`, biblio.biblionumber AS ID";
299-
$strcalc .= ", itemcallnumber as CALLNUM";
300-
$strcalc .= ", ccode as CCODE";
301-
$strcalc .= ", location as LOC";
298+
$strcalc .= "SELECT biblio.title, COUNT(biblio.biblionumber) AS `RANK`, biblio.biblionumber AS ID";
302299
$strcalc .= " , $colfield " if ($colfield);
303300
$strcalc .= " FROM `old_issues`
304301
LEFT JOIN items USING(itemnumber)
@@ -341,7 +338,7 @@ sub calculate {
341338
@$filters[12]=~ s/\*/%/g if (@$filters[12]);
342339
$strcalc .= " AND year(old_issues.issuedate) like '" . @$filters[12] ."'" if ( @$filters[12] );
343340

344-
$strcalc .= " group by biblio.biblionumber";
341+
$strcalc .= " group by biblio.biblionumber, biblio.title";
345342
$strcalc .= ", $colfield" if ($column);
346343
$strcalc .= " order by `RANK` DESC";
347344
$strcalc .= ", $colfield " if ($colfield);

0 commit comments

Comments
 (0)