Koha/t/db_dependent/Members_columns.t
Mark Tompsett 07716ca15b Bug 7785: remove MySQL-specific syntax from C4::Members::columns()
The initial thought was to remove this function. However,
tools/import_borrowers.pl uses it. So rather than remove
it to solve the problem, it was reworked to a more generic
solution which runs faster.

By accessing $sth->{NAME} directly, the driver becomes
responsible for filling it correctly. This happens when a SELECT
is done on the borrowers table. It does not even have to have
data in the result set!

The columns method could be more generic and used elsewhere too.
Comparison between the old method and the STH method showed a
significant time difference. The old method took 35 seconds
for 40k iterations versus 19 seconds for the same amount of
iterations with the STH method regardless of the size of the
borrowers table.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-08-13 16:14:35 +00:00

24 lines
492 B
Perl

#!/usr/bin/perl
#
# This is to test C4/Members
# It requires a working Koha database with the sample data
use Modern::Perl;
use Test::More tests => 2;
BEGIN {
use_ok('C4::Members');
}
my @borrowers_columns = C4::Members->columns;
ok(
$#borrowers_columns > 1,
'C4::Member->column returned a reasonable number of columns ('
. ( $#borrowers_columns + 1 ) . ')'
)
or diag(
'WARNING: Check that the borrowers table exists and has the correct fields defined.'
);
exit;