From a93e49131d4d22c5bc2123f9a3626c36845d9e07 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Feb 2018 13:39:51 -0300 Subject: [PATCH] Bug 20144: [sql_modes] Remove ORDER BY clause for COUNT(*) in GetItemsForInventory 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 Signed-off-by: Julian Maurice Signed-off-by: Jonathan Druart --- C4/Items.pm | 2 +- t/db_dependent/Items/GetItemsForInventory.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 2a2a6407e0..d0357f68d4 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -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); diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t index 452b15eb66..17ab8c1615 100755 --- a/t/db_dependent/Items/GetItemsForInventory.t +++ b/t/db_dependent/Items/GetItemsForInventory.t @@ -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); -- 2.39.5