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

(-)a/C4/Reports/Guided.pm (-3 / +6 lines)
Lines 431-440 sub nb_rows { Link Here
431
    });
431
    });
432
432
433
    $sth->execute();
433
    $sth->execute();
434
    my $results = $sth->fetch;
435
    my $n = $results ? $results->[0] : 0;
436
434
437
    return $n;
435
    if ( $sth->errstr ) {
436
        return 0;
437
    }
438
    else {
439
       return $sth->fetch->[0];
440
    }
438
}
441
}
439
442
440
=head2 execute_query
443
=head2 execute_query
(-)a/t/db_dependent/Reports/Guided.t (-2 / +12 lines)
Lines 413-419 $schema->storage->txn_rollback; Link Here
413
413
414
subtest 'nb_rows() tests' => sub {
414
subtest 'nb_rows() tests' => sub {
415
415
416
    plan tests => 1;
416
    plan tests => 3;
417
417
418
    $schema->storage->txn_begin;
418
    $schema->storage->txn_begin;
419
419
Lines 430-435 subtest 'nb_rows() tests' => sub { Link Here
430
430
431
    is( $nb_rows, $items_count, 'nb_rows returns the right value' );
431
    is( $nb_rows, $items_count, 'nb_rows returns the right value' );
432
432
433
    my $bad_query = q{
434
        SELECT * items xxx
435
    };
436
437
    warning_like
438
        { $nb_rows = nb_rows( $bad_query ) }
439
        qr/^DBD::mysql::st execute failed:/,
440
        'Bad queries raise a warning';
441
442
    is( $nb_rows, 0, 'nb_rows returns 0 on bad queries' );
443
433
    $schema->storage->txn_rollback;
444
    $schema->storage->txn_rollback;
434
};
445
};
435
446
436
- 

Return to bug 23624