From: Brandon L. Black Date: Tue, 7 Feb 2006 03:47:39 +0000 (+0000) Subject: rollback on disconnect, and disconnect on DESTROY X-Git-Tag: v0.05005~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9292561714255448d9ac3aa96eaacb287537ab24;p=dbsrgits%2FDBIx-Class.git rollback on disconnect, and disconnect on DESTROY --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 296a688..c218ef1 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -222,7 +222,11 @@ sub debugcb { sub disconnect { my ($self) = @_; - $self->_dbh->disconnect if $self->_dbh; + if( $self->connected ) { + $self->_dbh->rollback unless $self->_dbh->{AutoCommit}; + $self->_dbh->disconnect; + $self->_dbh(undef); + } } sub connected { @@ -420,6 +424,8 @@ sub columns_info_for { return \%result; } +sub DESTROY { shift->disconnect } + 1; =head1 ENVIRONMENT VARIABLES