Bug 20144: [sql_modes] Remove ORDER BY clause for COUNT(*) in GetItemsForInventory
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 6 Feb 2018 16:39:51 +0000 (13:39 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Feb 2018 16:59:00 +0000 (13:59 -0300)
Fix for:
DBD::mysql::st execute failed: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause [for Statement 'SELECT COUNT(*)

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/Items.pm
t/db_dependent/Items/GetItemsForInventory.t

index 2a2a640..d0357f6 100644 (file)
@@ -884,8 +884,8 @@ sub GetItemsForInventory {
         $query .= 'WHERE ';
         $query .= join ' AND ', @where_strings;
     }
-    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
     my $count_query = $select_count . $query;
+    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
     $query .= " LIMIT $offset, $size" if ($offset and $size);
     $query = $select_columns . $query;
     my $sth = $dbh->prepare($query);
index 452b15e..17ab8c1 100755 (executable)
@@ -123,8 +123,8 @@ sub OldWay {
         $query .= 'WHERE ';
         $query .= join ' AND ', @where_strings;
     }
-    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
     my $count_query = $select_count . $query;
+    $query .= ' ORDER BY items.cn_sort, itemcallnumber, title';
     $query .= " LIMIT $offset, $size" if ($offset and $size);
     $query = $select_columns . $query;
     my $sth = $ldbh->prepare($query);