From: Peter Rabbitson Date: Sat, 12 Dec 2009 23:19:57 +0000 (+0000) Subject: Fix corner case regression on search_related on a prefetching rs X-Git-Tag: v0.08116~61^2~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1edfd0dcc6e483fa3506adbbc7b6d8cc7bf45abc;p=dbsrgits%2FDBIx-Class.git Fix corner case regression on search_related on a prefetching rs --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 6af5f63..6d0486b 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2638,10 +2638,19 @@ sub _chain_relationship { || $self->_has_resolved_attr (@force_subq_attrs) ) { + # Nuke the prefetch (if any) before the new $rs attrs + # are resolved (prefetch is useless - we are wrapping + # a subquery anyway). + my $rs_copy = $self->search; + $rs_copy->{attrs}{join} = $self->_merge_attr ( + $rs_copy->{attrs}{join}, + delete $rs_copy->{attrs}{prefetch}, + ); + $from = [{ -source_handle => $source->handle, -alias => $attrs->{alias}, - $attrs->{alias} => $self->as_query, + $attrs->{alias} => $rs_copy->as_query, }]; delete @{$attrs}{@force_subq_attrs, 'where'}; $seen->{-relation_chain_depth} = 0;