fix Cursor SYNOPSIS
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Storage / DBI / Cursor.pm
index d1f1c6e..e4f7d39 100644 (file)
@@ -3,14 +3,13 @@ package DBIx::Class::Storage::DBI::Cursor;
 use strict;
 use warnings;
 
-use base qw/
-  Class::Accessor::Grouped
-  DBIx::Class::Cursor
-/;
-use mro 'c3';
+use base qw/DBIx::Class::Cursor/;
+
+use Try::Tiny;
+use namespace::clean;
 
 __PACKAGE__->mk_group_accessors('simple' =>
-    qw/sth/
+    qw/sth storage args pos attrs _dbh_gen/
 );
 
 =head1 NAME
@@ -21,7 +20,12 @@ resultset.
 =head1 SYNOPSIS
 
   my $cursor = $schema->resultset('CD')->cursor();
-  my $first_cd = $cursor->next;
+
+  # raw values off the database handle in resultset columns/select order
+  my @next_cd_column_values = $cursor->next;
+
+  # list of all raw values as arrayrefs
+  my @all_cds_column_values = $cursor->all;
 
 =head1 DESCRIPTION
 
@@ -128,7 +132,7 @@ sub _dbh_all {
   my ($storage, $dbh, $self) = @_;
 
   $self->_check_dbh_gen;
-  $self->sth->finish if $self->sth->{Active};
+  $self->sth->finish if $self->sth && $self->sth->{Active};
   $self->sth(undef);
   my ($rv, $sth) = $storage->_select(@{$self->{args}});
   return @{$sth->fetchall_arrayref};
@@ -154,8 +158,10 @@ sub reset {
   my ($self) = @_;
 
   # No need to care about failures here
-  eval { $self->sth->finish if $self->sth && $self->sth->{Active} };
+  try { $self->sth->finish }
+    if $self->sth && $self->sth->{Active};
   $self->_soft_reset;
+  return undef;
 }
 
 sub _soft_reset {
@@ -164,7 +170,6 @@ sub _soft_reset {
   $self->sth(undef);
   delete $self->{done};
   $self->{pos} = 0;
-  return $self;
 }
 
 sub _check_dbh_gen {
@@ -177,11 +182,11 @@ sub _check_dbh_gen {
 }
 
 sub DESTROY {
-  my ($self) = @_;
-
   # None of the reasons this would die matter if we're in DESTROY anyways
-  local $@;
-  eval { $self->sth->finish if $self->sth && $self->sth->{Active} };
+  if (my $sth = $_[0]->sth) {
+    local $SIG{__WARN__} = sub {};
+    try { $sth->finish } if $sth->FETCH('Active');
+  }
 }
 
 1;