From f15cff7d8815b40c6cdeff8def58799b0a497490 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 5 Feb 2018 18:13:06 -0300 Subject: [PATCH] Bug 20177: [sql_modes] Fix GROUP BY clause in GetCourses Fix for: 'koha_kohadev.courses.department' isn't in GROUP BY t/db_dependent/CourseReserves.t A better fix would be to remove the joins and only return values from the courses table. But more work is needed to acchieve that goal. Signed-off-by: Owen Leonard Test passes and the behavior of Course reserves appears to be unchanged Signed-off-by: Julian Maurice Signed-off-by: Nick Clemens (cherry picked from commit 88c29de46558f974ae10a6d25096cf531f7ee0a0) Signed-off-by: Martin Renvoize --- C4/CourseReserves.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 3a3f422a96..2b1ef027df 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -162,9 +162,9 @@ sub GetCourses { my @query_values; my $query = " - SELECT courses.* - FROM courses - LEFT JOIN course_reserves ON course_reserves.course_id = courses.course_id + SELECT c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp + FROM courses c + LEFT JOIN course_reserves ON course_reserves.course_id = c.course_id LEFT JOIN course_items ON course_items.ci_id = course_reserves.ci_id "; @@ -180,7 +180,7 @@ sub GetCourses { $query .= join( ' AND ', @query_keys ); } - $query .= " GROUP BY courses.course_id "; + $query .= " GROUP BY c.course_id, c.department, c.course_number, c.section, c.course_name, c.term, c.staff_note, c.public_note, c.students_count, c.enabled, c.timestamp "; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare($query); -- 2.39.5