$self->simplify_joins( \%simplifiedResult, $joinSpec, \%requiredSetOfRelations || undef);
Take all data in $joinSpec (which can be anything DBIC will accept, which includes hashes and arrays) and eliminate any relation not mentioned in \%requiredSetOfRelations. If %requiredSetOfRelations is undef, no relations are eliminated.
This function converts things like [ { a => b }, { a => { b => c } }, a, a => [ d, f ], ] into { a => { b => { c => {}, }, d => {}, f => {} } } resulting in a minimum of joined tables.
This routine would be a little nicer if the output were { a => [ { b => c }, d, f ] } but that would be a lot of work, and nothing to gain.
Note that for DBIC, regardless of nesting, the relations must each have unique names, which is why %requiredSetOfRelations is a one-level hash rather than a tree of hashes. However, the joins must be specified to DBIC as a tree.
unless (ref($item)) {
$hash->{$item} = 1;
return $hash;
}
if (ref($item) eq 'HASH') {
foreach my $i (keys %$item, values %$item) {
$self->addToFlatHashref($hash,$i);
}
return $hash;
}
if (ref($item) eq 'ARRAY') {
foreach my $i (@$item) {
$self->addToFlatHashref($hash,$i);
}
return $hash;
}
return $hash;
}
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 396:
=pod directives shouldn't be over one line long! Ignoring all 5 lines of content