forked from bluescreen10/dbd-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
030_st_execute_array.t
34 lines (25 loc) · 902 Bytes
/
030_st_execute_array.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use Test::More;
# test style cribbed from t/013_st_execute_bound_params.t
BEGIN {
use_ok('DBD::Mock');
use_ok('DBI');
}
my $sql = 'INSERT INTO staff (first_name, last_name, dept) VALUES(?, ?, ?)';
{
my $dbh = DBI->connect( 'DBI:Mock:', '', '' );
my $sth = eval { $dbh->prepare( $sql ) };
# taken from: https://metacpan.org/module/DBI#Statement-Handle-Methods
$dbh->{RaiseError} = 1; # save having to check each method call
$sth = $dbh->prepare($sql);
$sth->bind_param_array(1, [ 'John', 'Mary', 'Tim' ]);
$sth->bind_param_array(2, [ 'Booth', 'Todd', 'Robinson' ]);
# TODO: $sth->bind_param_array(3, "SALES"); # scalar will be reused for each row
eval {
$sth->execute_array( { ArrayTupleStatus => \my @tuple_status } );
};
ok( ! $@, 'Called execute_array() ok' )
or diag $@;
}
done_testing;