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

(-)a/C4/Reports/Guided.pm (-2 / +2 lines)
Lines 1001-1008 sub convert_sql { Link Here
1001
    my ( $sql ) = @_;
1001
    my ( $sql ) = @_;
1002
    my $updated_sql = $sql;
1002
    my $updated_sql = $sql;
1003
    if ( $sql =~ m|biblioitems| and $sql =~ m|marcxml| ) {
1003
    if ( $sql =~ m|biblioitems| and $sql =~ m|marcxml| ) {
1004
        $updated_sql =~ s|biblioitems|biblio_metadata|;
1004
        $updated_sql =~ s|biblioitems|biblio_metadata|g;
1005
        $updated_sql =~ s|marcxml|metadata|;
1005
        $updated_sql =~ s|marcxml|metadata|g;
1006
    }
1006
    }
1007
    return $updated_sql;
1007
    return $updated_sql;
1008
}
1008
}
(-)a/t/db_dependent/Reports/Guided.t (-2 / +12 lines)
Lines 289-295 subtest 'Ensure last_run is populated' => sub { Link Here
289
};
289
};
290
290
291
subtest 'convert_sql' => sub {
291
subtest 'convert_sql' => sub {
292
    plan tests => 3;
292
    plan tests => 4;
293
293
294
    my $sql = q|
294
    my $sql = q|
295
    SELECT biblionumber, ExtractValue(marcxml,
295
    SELECT biblionumber, ExtractValue(marcxml,
Lines 341-346 count(h.reservedate) AS 'holds' Link Here
341
    GROUP BY b.biblionumber
341
    GROUP BY b.biblionumber
342
    HAVING count(h.reservedate) >= 42|;
342
    HAVING count(h.reservedate) >= 42|;
343
    is( C4::Reports::Guided::convert_sql( $sql ), $expected_converted_sql, "Query with 2 joins should have been correctly converted");
343
    is( C4::Reports::Guided::convert_sql( $sql ), $expected_converted_sql, "Query with 2 joins should have been correctly converted");
344
345
    $sql = q|
346
    SELECT t1.marcxml AS first, t2.marcxml AS second,
347
    FROM biblioitems t1
348
    LEFT JOIN biblioitems t2 USING ( biblionumber )|;
349
350
    $expected_converted_sql = q|
351
    SELECT t1.metadata AS first, t2.metadata AS second,
352
    FROM biblio_metadata t1
353
    LEFT JOIN biblio_metadata t2 USING ( biblionumber )|;
354
    is( C4::Reports::Guided::convert_sql( $sql ), $expected_converted_sql, "Query with multiple instances of marcxml and biblioitems should have them all replaced");
344
};
355
};
345
356
346
$schema->storage->txn_rollback;
357
$schema->storage->txn_rollback;
347
- 

Return to bug 19495