my $collapse = $attrs->{collapse} || {};
if (my $prefetch = delete $attrs->{prefetch}) {
+ $prefetch = $self->_merge_attr({}, $prefetch);
my @pre_order;
+ my $seen = $attrs->{seen_join} || {};
foreach my $p (ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch)) {
# bring joins back to level of current class
my @prefetch = $source->resolve_prefetch(
- $p, $alias, { %{$attrs->{seen_join}||{}} }, \@pre_order, $collapse
+ $p, $alias, $seen, \@pre_order, $collapse
);
push(@{$attrs->{select}}, map { $_->[0] } @prefetch);
push(@{$attrs->{as}}, map { $_->[1] } @prefetch);
use Data::Dumper;
my $schema = DBICTest->init_schema();
-plan tests => 18;
+plan tests => 19;
my @rs1a_results = $schema->resultset("Artist")->search_related('cds', {title => 'Forkful of bees'}, {order_by => 'title'});
is($rs1a_results[0]->title, 'Forkful of bees', "bare field conditions okay after search related");
is(scalar(@{$merge_rs_2->{attrs}->{join}}), 1, 'only one join kept when inherited');
my $merge_rs_2_cd = $merge_rs_2->next;
+eval {
+
+ my @rs_with_prefetch = $schema->resultset('TreeLike')
+ ->search(
+ {'me.id' => 1},
+ {
+ prefetch => [ 'parent', { 'children' => 'parent' } ],
+ });
+
+};
+
+ok(!$@, "pathological prefetch ok");
+
1;