# the fake group_by is so that the pruner throws away all non-selecting, non-restricting
# multijoins (since we def. do not care about those inside the subquery)
- my $subq_joinspec = do {
+ my $inner_subq = do {
# must use it here regardless of user requests
local $self->{_use_join_optimizer} = 1;
local $self->{_use_join_optimizer} = 0;
# generate the subquery
- my $subq = $self->_select_args_to_query (
+ $self->_select_args_to_query (
$inner_from,
$inner_select,
$where,
$inner_attrs,
);
-
- +{
- -alias => $attrs->{alias},
- -rsrc => $inner_from->[0]{-rsrc},
- $attrs->{alias} => $subq,
- };
};
# Generate the outer from - this is relatively easy (really just replace
$j = [ $j ] unless ref $j eq 'ARRAY'; # promote the head-from to an AoH
if ($j->[0]{-alias} eq $attrs->{alias}) { # time to swap
+
push @outer_from, [
- $subq_joinspec,
+ {
+ -alias => $attrs->{alias},
+ -rsrc => $j->[0]{-rsrc},
+ $attrs->{alias} => $inner_subq,
+ },
@{$j}[1 .. $#$j],
];
last; # we'll take care of what's left in $from below
or next;
$return{$col} = {
- %{ ( $colinfos->{$source_alias} ||= $rsrc->columns_info )->{$colname} },
+ %{
+ ( $colinfos->{$source_alias} ||= $rsrc->columns_info )->{$colname}
+ ||
+ $self->throw_exception(
+ "No such column '$colname' on source " . $rsrc->source_name
+ );
+ },
-result_source => $rsrc,
-source_alias => $source_alias,
};