Skip Menu |

This queue is for tickets about the DBD-Mock CPAN distribution.

Report information
The Basics
Id: 15599
Status: resolved
Priority: 0/
Queue: DBD-Mock

People
Owner: stevan.little [...] gmail.com
Requestors: bwarfield [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.28
Fixed in: (no value)



Subject: Fatal error ("Not the same number of bound params") using DBD::Mock::Session for prepare/execute/execute sequence
Running the attached script using DBD::Mock 0.28 (also known as 1.31, which seems a bit confusing) produces the following error (paths lightly edited): DBD::Mock::st execute failed: Session Error: Not the same number of bound params in current state in DBD::Mock::Session (bugdemo) at lib/DBD/Mock.pm line 1092. at ./dbd-mock-bug1.pl line 27. Stepping through in the debugger reveals that on the second execute() call, the $tracker object has all four of the bind parameters in its list, when it should only have the second two. The problem can be worked around with the patch below, but this is an incorrect solution--a correct one probably requires maintaining more state between calls, but I don't know exactly what the desired behavior is. In the unlikely event that it matters, this bug is demonstrated in perl 5.6.1 on IRIX and on Linux 2.4.21. --- Mock.pm.orig Wed Jul 13 12:35:23 2005 +++ Mock.pm Mon Nov 7 10:07:31 2005 @@ -889,7 +889,7 @@ sub bound_param_trailing { my ($self, @values) = @_; - push @{$self->{bound_params}}, @values; + @{$self->{bound_params}} = @values; }
#!/usr/local/bin/perl use DBI; my $dbh = DBI->connect("dbi:Mock:",undef,undef,{RaiseError=>1,PrintError=>0}); my $SQL = "select foo from bar where a = ? and b = ?"; # the placeholders are for visual effect--they don't actually do # anything my $s = DBD::Mock::Session->new("bugdemo", { statement=> $SQL, bound_params=>[1,2], results=>[['foo'],[1]] }, { statement=> $SQL, bound_params=>[3,4], results=>[['foo'],[1]], }, ); $dbh->{mock_session} = $s; my $sth=$dbh->prepare($SQL); $sth->execute(1,2); $sth->execute(3,4); print "OK";
resolved in latest version due on CPAN later today