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

(-)a/Koha/Report.pm (+6 lines)
Lines 194-199 sub prep_report { Link Here
194
    }
194
    }
195
195
196
    my %lookup;
196
    my %lookup;
197
    unless ( scalar @$param_names ) {
198
        my @placeholders = $sql =~ /<<([^<>]+)>>/g;
199
        foreach my $placeholder (@placeholders) {
200
            push @$param_names, $placeholder unless grep { $_ eq $placeholder } @$param_names;
201
        }
202
    }
197
    @lookup{@$param_names} = @$sql_params;
203
    @lookup{@$param_names} = @$sql_params;
198
    @split = split /<<|>>/, $sql;
204
    @split = split /<<|>>/, $sql;
199
    for ( my $i = 0 ; $i < $#split / 2 ; $i++ ) {
205
    for ( my $i = 0 ; $i < $#split / 2 ; $i++ ) {
(-)a/t/db_dependent/Koha/Reports.t (-3 / +2 lines)
Lines 66-73 subtest 'prep_report' => sub { Link Here
66
    ($sql, undef) = $report->prep_report( ['Test|list','Another'],["1\n12\n\r243",'the other'] );
66
    ($sql, undef) = $report->prep_report( ['Test|list','Another'],["1\n12\n\r243",'the other'] );
67
    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
    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');
68
68
69
    ($sql, undef) = $report->prep_report( [],["1\n12\n\r243",'the other',"42\n32\n22\n12"] );
69
    ($sql, undef) = $report->prep_report( [],["1\n12\n\r243",'the other'] );
70
    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');
70
    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');
71
71
72
    $report->savedsql(
72
    $report->savedsql(
73
        q{SELECT  i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]] FROM items})
73
        q{SELECT  i.itemnumber, i.itemnumber as Exemplarnummber, [[i.itemnumber| itemnumber for batch]] FROM items})
74
- 

Return to bug 32413