From: Matt S Trout <mst@shadowcat.co.uk>
Date: Tue, 14 Mar 2006 01:06:13 +0000 (+0000)
Subject: Fixed hm prefetch
X-Git-Tag: v0.06000~60^2~24
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=479ed4231d5f405d559f8614892fba579064b1f8;p=dbsrgits%2FDBIx-Class.git

Fixed hm prefetch
---

diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm
index 3ce9489..07ca30e 100644
--- a/lib/DBIx/Class/ResultSet.pm
+++ b/lib/DBIx/Class/ResultSet.pm
@@ -566,10 +566,13 @@ sub all {
       # If we're collapsing has_many prefetches it probably makes
       # very little difference, and this is cleaner than hacking
       # _construct_object to survive the approach
-    my @row;
     $self->cursor->reset;
-    while (@row = $self->cursor->next) {
+    my @row = $self->cursor->next;
+    while (@row) {
       push(@obj, $self->_construct_object(@row));
+      @row = (exists $self->{stashed_row}
+               ? @{delete $self->{stashed_row}}
+               : $self->cursor->next);
     }
   } else {
     @obj = map { $self->_construct_object(@$_) } $self->cursor->all;
diff --git a/t/run/23cache.tl b/t/run/23cache.tl
index 1f85dcb..3f98204 100644
--- a/t/run/23cache.tl
+++ b/t/run/23cache.tl
@@ -3,7 +3,7 @@ my $schema = shift;
 
 eval "use DBD::SQLite";
 plan skip_all => 'needs DBD::SQLite for testing' if $@;
-plan tests => 15;
+plan tests => 16;
 
 my $rs = $schema->resultset("Artist")->search(
   { artistid => 1 }