Lines 124-130
Generates the DBIC prefetch attribute based on embedded relations, and merges in
Link Here
|
124 |
return unless defined $embed; |
124 |
return unless defined $embed; |
125 |
|
125 |
|
126 |
my @prefetches; |
126 |
my @prefetches; |
127 |
foreach my $key (keys %{$embed}) { |
127 |
foreach my $key (sort keys(%{$embed})) { |
128 |
my $parsed = _parse_prefetch($key, $embed, $result_set); |
128 |
my $parsed = _parse_prefetch($key, $embed, $result_set); |
129 |
push @prefetches, $parsed if defined $parsed; |
129 |
push @prefetches, $parsed if defined $parsed; |
130 |
} |
130 |
} |
Lines 353-372
sub _merge_embed {
Link Here
|
353 |
sub _parse_prefetch { |
353 |
sub _parse_prefetch { |
354 |
my ( $key, $embed, $result_set) = @_; |
354 |
my ( $key, $embed, $result_set) = @_; |
355 |
|
355 |
|
356 |
return unless exists $result_set->prefetch_whitelist->{$key}; |
356 |
my $pref_key = $key; |
|
|
357 |
$pref_key =~ s/_count$// if $embed->{$key}->{is_count}; |
358 |
return unless exists $result_set->prefetch_whitelist->{$pref_key}; |
357 |
|
359 |
|
358 |
my $ko_class = $result_set->prefetch_whitelist->{$key}; |
360 |
my $ko_class = $result_set->prefetch_whitelist->{$pref_key}; |
359 |
return $key unless defined $embed->{$key}->{children} && defined $ko_class; |
361 |
return $pref_key unless defined $embed->{$key}->{children} && defined $ko_class; |
360 |
|
362 |
|
361 |
my $prefetch = {}; |
363 |
my @prefetches; |
362 |
foreach my $child (keys %{$embed->{$key}->{children}}) { |
364 |
foreach my $child (sort keys(%{$embed->{$key}->{children}})) { |
363 |
my $parsed = _parse_prefetch($child, $embed->{$key}->{children}, $ko_class->new); |
365 |
my $parsed = _parse_prefetch($child, $embed->{$key}->{children}, $ko_class->new); |
364 |
$prefetch->{$key} = $parsed if defined $parsed; |
366 |
push @prefetches, $parsed if defined $parsed; |
365 |
} |
367 |
} |
366 |
|
368 |
|
367 |
return unless scalar(keys %{$prefetch}); |
369 |
return $pref_key unless scalar(@prefetches); |
368 |
|
370 |
|
369 |
return $prefetch; |
371 |
return {$pref_key => $prefetches[0]} if scalar(@prefetches) eq 1; |
|
|
372 |
|
373 |
return {$pref_key => \@prefetches}; |
370 |
} |
374 |
} |
371 |
|
375 |
|
372 |
sub _from_api_param { |
376 |
sub _from_api_param { |
373 |
- |
|
|