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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
# this is bug RT #71438
use 5.008;
use strict;
use warnings;
use Test::More;
use DBI;
my $dbh = DBI->connect('dbi:Mock:', '', '', { PrintError => 0, RaiseError => 1});
my $query = 'SELECT foo, bar FROM baz WHERE id=?';
my @session = (
{
statement => $query,
results => [
['foo', 'bar'],
[1, 'test1'],
[2, 'test2']
],
bound_params => [ 1 ],
},
{
statement => $query,
results => [
['abc', 'xyz'],
[7, 'test7'],
[8, 'test8']
],
bound_params => [ 2 ],
},
);
$dbh->{mock_session} = DBD::Mock::Session->new(@session);
# First query
my $sth = $dbh->prepare($query);
$sth->execute(1);
is_deeply(
$sth->fetchrow_hashref(),
{foo => 1, bar => 'test1'}
);
is_deeply(
$sth->fetchrow_hashref(),
{foo => 2, bar => 'test2'}
);
is_deeply(
$sth->fetchrow_hashref(),
undef
);
# Second query
$sth = $dbh->prepare($query);
$sth->execute(2);
is_deeply(
$sth->fetchrow_hashref(),
{abc => 7, xyz => 'test7'}
);
is_deeply(
$sth->fetchrow_hashref(),
{abc => 8, xyz => 'test8'}
);
is_deeply(
$sth->fetchrow_hashref(),
undef
);
done_testing();
|