rollback on disconnect, and disconnect on DESTROY
Brandon L. Black [Tue, 7 Feb 2006 03:47:39 +0000 (03:47 +0000)]
lib/DBIx/Class/Storage/DBI.pm

index 296a688..c218ef1 100644 (file)
@@ -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