View | Details | Raw Unified | Return to bug 33584
Collapse All | Expand All

(-)a/Koha/Database/Commenter.pm (-1 / +3 lines)
Lines 202-210 sub _fetch_schema_comments { Link Here
202
sub _fetch_stored_comments {
202
sub _fetch_stored_comments {
203
    my ( $self, $params ) = @_; # params: table
203
    my ( $self, $params ) = @_; # params: table
204
    my $sql = q|
204
    my $sql = q|
205
SELECT table_name, column_name, column_comment FROM information_schema.columns
205
SELECT table_name AS `table_name`, column_name AS `column_name`, column_comment AS `column_comment`
206
FROM information_schema.columns
206
WHERE table_schema=? AND table_name=?
207
WHERE table_schema=? AND table_name=?
207
ORDER BY table_name, column_name|;
208
ORDER BY table_name, column_name|;
209
# The AS `table_name` etc. is needed for MySQL8 which returns uppercase columns in information_schema
208
    $sql =~ s/AND table_name=\?// unless $params->{table};
210
    $sql =~ s/AND table_name=\?// unless $params->{table};
209
    return $self->{dbh}->selectall_arrayref( $sql, { Slice => {} }, $self->{database}, $params->{table} || () );
211
    return $self->{dbh}->selectall_arrayref( $sql, { Slice => {} }, $self->{database}, $params->{table} || () );
210
}
212
}
(-)a/t/db_dependent/Koha/Database/Commenter.t (-2 / +7 lines)
Lines 15-21 our $dbh = C4::Context->dbh; Link Here
15
our $mgr;
15
our $mgr;
16
16
17
subtest '->new, dry_run' => sub {
17
subtest '->new, dry_run' => sub {
18
    plan tests => 6;
18
    plan tests => 9;
19
    $schema->storage->txn_begin; # just cosmetic, no changes expected in a dry run
19
    $schema->storage->txn_begin; # just cosmetic, no changes expected in a dry run
20
20
21
    # Two exceptions on dbh parameter
21
    # Two exceptions on dbh parameter
Lines 28-33 subtest '->new, dry_run' => sub { Link Here
28
    unlink $filename;
28
    unlink $filename;
29
    throws_ok { $mgr->reset_to_schema({ dry_run => 1, table => 'biblio' }) } 'Koha::Exceptions::FileNotFound', 'Schema deleted';
29
    throws_ok { $mgr->reset_to_schema({ dry_run => 1, table => 'biblio' }) } 'Koha::Exceptions::FileNotFound', 'Schema deleted';
30
30
31
    # Check case of columns from information_schema (MySQL8 defaults to uppercase)
32
    my $columns = $mgr->_fetch_stored_comments({ table => 'article_requests' });
33
    ok( exists $columns->[0]->{table_name}, 'Check table_name column' );
34
    ok( exists $columns->[0]->{column_name}, 'Check column_name column' );
35
    ok( exists $columns->[0]->{column_comment}, 'Check column_comment column' );
36
31
    # Clear comments for article_requests in dry run mode
37
    # Clear comments for article_requests in dry run mode
32
    my $messages = [];
38
    my $messages = [];
33
    $mgr->clear( { table => 'article_requests', dry_run => 1 }, $messages );
39
    $mgr->clear( { table => 'article_requests', dry_run => 1 }, $messages );
34
- 

Return to bug 33584