Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

uploadin

  • Loading branch information...
commit 8d207010bd758c116d51943dc6053aa0b2e376be 1 parent 1dd83a0
Stevan Little authored
View
7 Changes
@@ -1,5 +1,12 @@
Revision history for Perl extension DBD::Mock.
+0.25 Sat Feb 26 2005
+ - removed the DBD::Mock::_error_handler routine
+ since it was actually redundant with the DBI::set_err
+ method. This was actually the source of the RT Bug #11515
+ which was found by Shlomi Fish (thanks Shlomi)
+ - adjusted some tests for this fix
+
0.24 Fri Jan 28 2005
- added the reset() method to the DBD::Mock::Session
object so that a session can be used more than once.
View
2  META.yml
@@ -1,6 +1,6 @@
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: DBD-Mock
-version: 0.24
+version: 0.25
version_from: VERSION
installdirs: site
requires:
View
2  Makefile.PL
@@ -8,5 +8,5 @@ WriteMakefile(
},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/DBD/Mock.pm', # retrieve abstract from module
- AUTHOR => 'Chris Winters <chris@cwinters.com>') : ()),
+ AUTHOR => 'Chris Winters <chris@cwinters.com> & Stevan Little <stevan@iinteractive.com>') : ()),
);
View
2  VERSION
@@ -1 +1 @@
-$VERSION = '0.24';
+$VERSION = '0.25';
View
27 lib/DBD/Mock.pm
@@ -19,7 +19,7 @@ use warnings;
require DBI;
-our $VERSION = '1.27';
+our $VERSION = '1.28';
our $drh = undef; # will hold driver handle
our $err = 0; # will hold any error codes
@@ -42,17 +42,6 @@ sub driver {
sub CLONE { undef $drh }
-sub _error_handler {
- my ($dbh, $error) = @_;
- $dbh->DBI::set_err(1, $error);
- if ($dbh->{'PrintError'}) {
- warn "$error\n";
- }
- elsif ($dbh->{'RaiseError'}) {
- die "$error\n";
- }
-}
-
# NOTE:
# this feature is still quite experimental. It is defaulted to
# be off, but it can be turned on by doing this:
@@ -182,7 +171,7 @@ sub prepare {
if ($@) {
my $parser_error = $@;
chomp $parser_error;
- DBD::Mock::_error_handler($dbh, "Failed to parse statement. Error: ${parser_error}. Statement: ${statement}");
+ $dbh->DBI::set_err(1, "Failed to parse statement. Error: ${parser_error}. Statement: ${statement}");
return undef;
}
@@ -193,7 +182,7 @@ sub prepare {
if ($@) {
my $session_error = $@;
chomp $session_error;
- DBD::Mock::_error_handler($dbh, "Session Error: ${session_error}. Statement: ${statement}");
+ $dbh->DBI::set_err(1, "Session Error: ${session_error}. Statement: ${statement}");
return undef;
}
}
@@ -235,7 +224,7 @@ sub prepare {
# connection present.
unless ($dbh->FETCH('Active')) {
- DBD::Mock::_error_handler($dbh, "No connection present");
+ $dbh->DBI::set_err(1, "No connection present");
return undef;
}
@@ -322,7 +311,7 @@ sub STORE {
unless ($is_valid_parser) {
my $error = "Parser must be a code reference or object with 'parse()' " .
"method (Given type: '$parser_type')";
- DBD::Mock::_error_handler($dbh, $error);
+ $dbh->DBI::set_err(1, $error);
return undef;
}
push @{$dbh->{mock_parser}}, $value;
@@ -401,7 +390,7 @@ sub execute {
my ($sth, @params) = @_;
unless ($sth->{Database}->{mock_can_connect}) {
- DBD::Mock::_error_handler($sth->{Database}, "No connection present");
+ $sth->{Database}->DBI::set_err(1, "No connection present");
return 0;
}
@@ -418,7 +407,7 @@ sub execute {
if ($@) {
my $session_error = $@;
chomp $session_error;
- DBD::Mock::_error_handler($dbh, "Session Error: ${session_error}");
+ $dbh->DBI::set_err(1, "Session Error: ${session_error}");
return undef;
}
}
@@ -433,7 +422,7 @@ sub fetch {
my ($sth) = @_;
unless ($sth->{Database}->{mock_can_connect}) {
- DBD::Mock::_error_handler($sth->{Database}, "No connection present");
+ $sth->{Database}->DBI::set_err(1, "No connection present");
return undef;
}
View
6 t/12_db_can_connect.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 23;
+use Test::More tests => 22;
BEGIN {
use_ok('DBD::Mock');
@@ -35,7 +35,7 @@ BEGIN {
ok($@, '... we should have an exception');
like($@,
- qr/^No connection present/,
+ qr/No connection present/,
'Preparing statement against inactive handle throws expected exception' );
like($dbh->errstr,
@@ -68,7 +68,7 @@ BEGIN {
ok(!$dbh->ping(), '...and unsuccessfuly pinged handle (good)');
{ # isolate the warn handler
- $SIG{__WARN__} = sub {
+ local $SIG{__WARN__} = sub {
my $msg = shift;
like($msg, qr/No connection present/, '...got the expected warning');
};
View
10 t/14_db_parser.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 29;
+use Test::More tests => 26;
BEGIN {
use_ok('DBD::Mock');
@@ -37,8 +37,8 @@ BEGIN {
my $sth2 = eval { $dbh->prepare( 'SELECT * FROM mytable' ) };
ok(!defined($sth2), '... we should get nothing back from here');
- is($@,
- qq(Failed to parse statement. Error: incorrect use of '*'. Statement: SELECT * FROM mytable\n),
+ like($@,
+ qr/Failed to parse statement\. Error\: incorrect use of \'\*\'\. Statement\: SELECT \* FROM mytable/,
'... parser failure generated correct error');
$dbh->disconnect();
@@ -77,7 +77,7 @@ BEGIN {
isa_ok($sth1, "DBI::st");
{ # isolate the warn handler
- $SIG{__WARN__} = sub {
+ local $SIG{__WARN__} = sub {
my $msg = shift;
like($msg,
qr/incorrect use of \'\*\'\. Statement\: SELECT \* FROM mytable/, #'
@@ -121,7 +121,7 @@ BEGIN {
cmp_ok($dbh->{PrintError}, '==', 1, '... make sure PrintError is set correctly');
{ # isolate the warn handler
- $SIG{__WARN__} = sub {
+ local $SIG{__WARN__} = sub {
my $msg = shift;
like($msg,
qr/Parser must be a code reference or /,
View
2  t/37_st_can_connect.t
@@ -32,7 +32,7 @@ ok(!$dbh->ping(), '... and ping returns false');
eval { $sth_exec->execute() };
ok($@, '... we got an exception');
-like($@, qr/^No connection present/, '... we got the expected execption');
+like($@, qr/No connection present/, '... we got the expected execption');
# turn off the database between execute and fetch
View
4 t/60_DBD_Mock_Session_test.t
@@ -100,7 +100,7 @@ use DBI;
Login::Test::login($dbh, 'user', '****')
};
ok($@, '... got the exception');
- like($@, qr/^Session Error\: Session states exhausted/, '... got the exception we expected');
+ like($@, qr/Session Error\: Session states exhausted/, '... got the exception we expected');
# reset the DBD::Mock::Session object
$successful_login->reset;
@@ -204,7 +204,7 @@ use DBI;
Login::Test::login($dbh, 'user', '****');
};
ok(defined($@), '... got an error, as expected');
- like($@, qr/^Session Error\: Session states exhausted\, /, '... got the error we expected');
+ like($@, qr/Session Error\: Session states exhausted\, /, '... got the error we expected');
}
Please sign in to comment.
Something went wrong with that request. Please try again.