Subject: | second prepare call before execute by first prepare will be die using DBD::Mock::Session |
At first, please see test.
----
use Test::More;
use DBI;
plan tests => 4;
my $dbr = DBI->install_driver('Mock');
isa_ok($dbr, 'DBI::dr');
my $dbh = DBI->connect('dbi:Mock:', '', '');
isa_ok($dbh, 'DBI::db');
$dbh->{mock_session} = DBD::Mock::Session->new(
+{
statement => q|SELECT foo_id FROM foo|,
results => [ [qw/foo_id/], [], ]
},
+{
statement => q|SELECT bar_id FROM bar|,
results => [ [qw/bar_id/], [], ]
},
);
my $sth_one = $dbh->prepare('SELECT foo_id FROM foo');
isa_ok($sth_one, 'DBI::st');
note($sth_one->{Statement});
# $dbh->{mock_session}->{state_index}++;
my $sth_two = $dbh->prepare('SELECT bar_id FROM bar');
# $dbh->{mock_session}->{state_index}--;
isa_ok($sth_two, 'DBI::st');
----
This test is not success.
I wonder if I should use DBD::Mock::Session or not when the case like?