Bug 20144: [sql_modes] Remove HAVING clause from GetTopIssues
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 6 Feb 2018 15:34:34 +0000 (12:34 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Feb 2018 16:58:58 +0000 (13:58 -0300)
Fix for:
'koha_kohadev.b.title' isn't in GROUP BY

t/db_dependent/Circulation/GetTopIssues.t

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Circulation.pm

index 8a97d00..2f75d8c 100644 (file)
@@ -3946,6 +3946,7 @@ sub GetTopIssues {
 
     my $dbh = C4::Context->dbh;
     my $query = q{
+        SELECT * FROM (
         SELECT b.biblionumber, b.title, b.author, bi.itemtype, bi.publishercode,
           bi.place, bi.publicationyear, b.copyrightdate, bi.pages, bi.size,
           i.ccode, SUM(i.issues) AS count
@@ -3983,11 +3984,13 @@ sub GetTopIssues {
     }
 
     $query .= q{
-        GROUP BY b.biblionumber
-        HAVING count > 0
+        GROUP BY b.biblionumber, b.title, b.author, bi.itemtype, bi.publishercode,
+          bi.place, bi.publicationyear, b.copyrightdate, bi.pages, bi.size,
+          i.ccode
         ORDER BY count DESC
     };
 
+    $query .= q{ ) xxx WHERE count > 0 };
     $count = int($count);
     if ($count > 0) {
         $query .= "LIMIT $count";