$sth->{Active} may throw during destruction >.<
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Cursor.pm
index 352ba08..eee5cbb 100644 (file)
@@ -6,6 +6,7 @@ use warnings;
 use base qw/DBIx::Class::Cursor/;
 
 use Try::Tiny;
+use namespace::clean;
 
 __PACKAGE__->mk_group_accessors('simple' =>
     qw/sth/
@@ -176,11 +177,10 @@ sub _check_dbh_gen {
 }
 
 sub DESTROY {
-  my ($self) = @_;
-
   # None of the reasons this would die matter if we're in DESTROY anyways
-  try { $self->sth->finish }
-    if $self->sth && $self->sth->{Active};
+  if (my $sth = $_[0]->sth) {
+    try { $sth->finish } if $sth->FETCH('Active');
+  }
 }
 
 1;