DBD::Mock bugfixes #1

Closed
wants to merge 7 commits into
from

2 participants

@wu-lee

Here's a request to pull my fixes - I hope the commit messages are mostly self explanatory. If not, please feel welcome to ask.

The original issue was RT #66815 (https://rt.cpan.org/Public/Bug/Display.html?id=66815), but I found some others and fixed those too.

N

wu-lee added some commits Mar 25, 2011
wu-lee Fix bug RT#66815 - check statement handles are valid before using them
$dbh->prepare does not guarantee to return a valid statement handle.
It may return a false value.  So check the returned value, and abort
if it is false, otherwise the error caused ->prepare to fail will get
overwritten by a less helpful one which says "Can't call method
'execute' on an undefined value" error.
6d8932e
wu-lee A test showing DBD::Mock->begin_work, commit and rollback don't detec…
…t ->prepare failure

This is reported in RT ticket #66815

Basically any call to ->begin_work, ->commit, >rollback made when
their internal call to ->prepare returns an invalid statement handle
will not notice and proceed to use it anyway.

In particular, this happens when a DBD::Mock::Session is in effect,
and the session state list has been exhausted.  When this happens, the
method in question fails with an unhelpful error "Can't use an
undefined value as an ARRAY reference at ../lib/DBD/Mock.pm line
635", masking the real reason.
2c12ab9
wu-lee Merge branch 'rt66815'
* rt66815:
  Fix bug RT#66815 - check statement handles are valid before using them
  A test showing DBD::Mock->begin_work, commit and rollback don't detect ->prepare failure
4dcccc7
wu-lee Add DBD::Mock::Session->current_state method
This just makes the code simpler to follow. Particularly the portion
in validate_bound_params where results are loaded into the $tracker
object.
23af0c7
wu-lee A test showing DBD::Mock::Session->verify_bound_params doesn't check …
…for session exhaustion

Basically it succeeds despite there being no states left to verify,
and on return the ->execute method fails with an unhelpful error
"Can't use an undefined value # as an ARRAY reference at
../lib/DBD/Mock.pm line 635."
3a1d41b
wu-lee Fix DBD::Mock::Session->verify_bound_params to check for state exhaus…
…tion
179e83a
wu-lee Merge branch 'fix-verify-bound-params'
* fix-verify-bound-params:
  Fix DBD::Mock::Session->verify_bound_params to check for state exhaustion
  A test showing DBD::Mock::Session->verify_bound_params doesn't check for session exhaustion
  Add DBD::Mock::Session->current_state method
09b2b02
@ginesr
Collaborator

Fixing in a separate branch to merge with master

@ginesr ginesr closed this Oct 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment