From: David Kamholz Date: Wed, 8 Mar 2006 17:23:51 +0000 (+0000) Subject: fix to find() for new prefetch code X-Git-Tag: v0.06000~60^2~53 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8389d4331846be56804dd464da2a4cf7e7ab0ca8;p=dbsrgits%2FDBIx-Class.git fix to find() for new prefetch code --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index b13d3a5..1af7e87 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -284,9 +284,13 @@ sub find { $query->{$self->{attrs}{alias}.'.'.$_} = delete $query->{$_}; } #warn Dumper($query); - return (keys %$attrs - ? $self->search($query,$attrs)->single - : $self->single($query)); + + if (keys %$attrs) { + my $rs = $self->search($query,$attrs); + return keys %{$rs->{collapse}} ? $rs->next : $rs->single; + } else { + return keys %{$self->{collapse}} ? $self->search($query)->next : $self->single($query); + } } =head2 search_related @@ -422,7 +426,9 @@ sub _construct_object { my ($self, @row) = @_; my @as = @{ $self->{attrs}{as} }; + warn "collapsing"; my $info = $self->_collapse_result(\@as, \@row); + warn "done collapsing"; my $new = $self->result_class->inflate_result($self->result_source, @$info);