From: Peter Rabbitson Date: Thu, 10 Sep 2009 17:32:03 +0000 (+0000) Subject: The real fix X-Git-Tag: v0.08112~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7c7995572f865613e5a1907189ac23d8b52c690;p=dbsrgits%2FDBIx-Class.git The real fix --- diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 4d0587a..53b0920 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -125,7 +125,10 @@ one value. sub next { my $self = shift; + + # using cursor so we don't inflate anything my ($row) = $self->_resultset->cursor->next; + return $row; } @@ -149,6 +152,8 @@ than row objects. sub all { my $self = shift; + + # using cursor so we don't inflate anything return map { $_->[0] } $self->_resultset->cursor->all; } @@ -172,7 +177,7 @@ Much like L. sub reset { my $self = shift; $self->_resultset->cursor->reset; - return undef; + return $self; } =head2 first @@ -194,8 +199,11 @@ Much like L but just returning the one value. sub first { my $self = shift; - $self->_resultset->reset(); + + # using cursor so we don't inflate anything + $self->_resultset->cursor->reset; my ($row) = $self->_resultset->cursor->next; + return $row; } @@ -396,7 +404,7 @@ sub throw_exception { # # Returns the underlying resultset. Creates it from the parent resultset if # necessary. -# +# sub _resultset { my $self = shift; diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index 3d59e84..3d5da26 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -148,6 +148,7 @@ sub reset { # No need to care about failures here eval { $self->{sth}->finish if $self->{sth} && $self->{sth}->{Active} }; $self->_soft_reset; + return undef; } sub _soft_reset { @@ -156,7 +157,6 @@ sub _soft_reset { delete $self->{sth}; delete $self->{done}; $self->{pos} = 0; - return $self; } sub _check_dbh_gen { diff --git a/t/88result_set_column.t b/t/88result_set_column.t index 066d4ee..dde817c 100644 --- a/t/88result_set_column.t +++ b/t/88result_set_column.t @@ -8,8 +8,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 21; - my $rs = $schema->resultset("CD")->search({}, { order_by => 'cdid' }); my $rs_title = $rs->get_column('title'); @@ -28,9 +26,8 @@ is($rs_title->min, 'Caterwaulin\' Blues', "min okay for title"); cmp_ok($rs_year->sum, '==', 9996, "three artists returned"); -my $reset_ret = $rs_year->reset; +$rs_year->reset; is($rs_year->next, 1999, "reset okay"); -is($reset_ret, undef, 'reset returns undef'); is($rs_year->first, 1999, "first okay"); @@ -95,3 +92,5 @@ is_deeply ( [ $rs->get_column ('cdid')->all ], 'prefetch properly collapses amount of rows from get_column', ); + +done_testing;