From: Rafael Kitover Date: Tue, 10 Nov 2009 12:16:18 +0000 (+0000) Subject: made commit/rollback when disconnected an exception X-Git-Tag: v0.08113~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6db5bdc68f2a9a725fa5fcc2d75dee743d30f7fd;p=dbsrgits%2FDBIx-Class.git made commit/rollback when disconnected an exception --- diff --git a/Changes b/Changes index f76cc0a..9c64870 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,7 @@ Revision history for DBIx::Class - Fixed another lingering problem with PostgreSQL auto-increment support and its interaction with multiple schemas + - Transaction support for MSSQL via DBD::Sybase 0.08112 2009-09-21 10:57:00 (UTC) - Remove the recommends from Makefile.PL, DBIx::Class is not diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1e558e8..2009df3 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1145,7 +1145,6 @@ sub _dbh_begin_work { sub txn_commit { my $self = shift; if ($self->{transaction_depth} == 1) { - my $dbh = $self->_dbh; $self->debugobj->txn_commit() if ($self->debug); $self->_dbh_commit; @@ -1161,7 +1160,9 @@ sub txn_commit { sub _dbh_commit { my $self = shift; - $self->_dbh->commit; + my $dbh = $self->_dbh + or $self->throw_exception('cannot COMMIT on a disconnected handle'); + $dbh->commit; } sub txn_rollback { @@ -1198,7 +1199,9 @@ sub txn_rollback { sub _dbh_rollback { my $self = shift; - $self->_dbh->rollback; + my $dbh = $self->_dbh + or $self->throw_exception('cannot ROLLBACK on a disconnected handle'); + $dbh->rollback; } # This used to be the top-half of _execute. It was split out to make it diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm index 7605080..5cd5aa1 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -37,14 +37,16 @@ sub _dbh_begin_work { sub _dbh_commit { my $self = shift; - - $self->_dbh->do('COMMIT'); + my $dbh = $self->_dbh + or $self->throw_exception('cannot COMMIT on a disconnected handle'); + $dbh->do('COMMIT'); } sub _dbh_rollback { my $self = shift; - - $self->_dbh->do('ROLLBACK'); + my $dbh = $self->_dbh + or $self->throw_exception('cannot ROLLBACK on a disconnected handle'); + $dbh->do('ROLLBACK'); } 1;