From 23f074ce2dc010af4c9d13d1a3eebf3a0b4c04d9 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 --- 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 a7154be82a..c765cc996f 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -882,8 +882,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.14.2