Browse Source

Bug 21603: Remove incorrect GROUP BY from C4::CourseReserves

'koha_kohadev.c.department' isn't in GROUP BY

Test plan:
Prove that the test fail without this patch and pass with this patch
applied (switch on the SQL modes)

Signed-off-by: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
18.11.x
Jonathan Druart 6 years ago
committed by Nick Clemens
parent
commit
41397c8553
  1. 8
      C4/CourseReserves.pm
  2. 5
      t/db_dependent/CourseReserves.t

8
C4/CourseReserves.pm

@ -966,9 +966,9 @@ sub SearchCourses {
my $enabled = $params{'enabled'} || '%';
my @params;
my $query = "SELECT c.* FROM courses c";
$query .= "
my $query = "
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_instructors ci
ON ( c.course_id = ci.course_id )
LEFT JOIN borrowers b
@ -992,7 +992,7 @@ sub SearchCourses {
)
AND
c.enabled LIKE ?
GROUP BY c.course_id
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
";
$term //= '';

5
t/db_dependent/CourseReserves.t

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 26;
use Test::More tests => 27;
use Koha::Database;
use t::lib::TestBuilder;
@ -136,4 +136,7 @@ DelCourse($course_id);
$course = GetCourse($course_id);
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" );
$courses = SearchCourses(); # FIXME Lack of tests for SearchCourses
is( ref($courses), 'ARRAY', 'SearchCourses should not crash and return an arrayref' );
$schema->storage->txn_rollback;

Loading…
Cancel
Save