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

(-)a/Koha/Report.pm (+6 lines)
Lines 152-157 sub prep_report { Link Here
152
    }
152
    }
153
153
154
    my %lookup;
154
    my %lookup;
155
    unless ( scalar @$param_names ) {
156
        my @placeholders = $sql =~ /<<([^<>]+)>>/g;
157
        foreach my $placeholder (@placeholders) {
158
            push @$param_names, $placeholder unless grep { $_ eq $placeholder } @$param_names;
159
        }
160
    }
155
    @lookup{@$param_names} = @$sql_params;
161
    @lookup{@$param_names} = @$sql_params;
156
    @split = split /<<|>>/, $sql;
162
    @split = split /<<|>>/, $sql;
157
    for ( my $i = 0 ; $i < $#split / 2 ; $i++ ) {
163
    for ( my $i = 0 ; $i < $#split / 2 ; $i++ ) {
(-)a/t/db_dependent/Koha/Reports.t (-3 / +2 lines)
Lines 65-72 subtest 'prep_report' => sub { Link Here
65
    ($sql, undef) = $report->prep_report( ['Test|list','Another'],["1\n12\n\r243",'the other'] );
65
    ($sql, undef) = $report->prep_report( ['Test|list','Another'],["1\n12\n\r243",'the other'] );
66
    is( $sql, qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* saved_sql.id: $id */},'Expected sql generated correctly with multiple params and names');
66
    is( $sql, qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* saved_sql.id: $id */},'Expected sql generated correctly with multiple params and names');
67
67
68
    ($sql, undef) = $report->prep_report( [],["1\n12\n\r243",'the other',"42\n32\n22\n12"] );
68
    ($sql, undef) = $report->prep_report( [],["1\n12\n\r243",'the other'] );
69
    is( $sql, qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('42','32','22','12') /* saved_sql.id: $id */},'Expected sql generated correctly with multiple params and no names');
69
    is( $sql, qq{SELECT * FROM items WHERE itemnumber IN ('1','12','243') AND 'the other' AND ('1','12','243') /* saved_sql.id: $id */},'Expected sql generated correctly with multiple params and no names');
70
70
71
    $report->savedsql(
71
    $report->savedsql(
72
        q{SELECT  i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]] FROM items})
72
        q{SELECT  i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]] FROM items})
73
- 

Return to bug 32413