use Data::Query::ExprHelpers;
use Moo::Role;
-sub _subquery_remap {
+sub _subquery_remap_select {
my ($self, $orig_select) = @_;
my $gensym_count;
}
} @{$orig_select->{select}};
+ my @outside_select_list = map {
+ if (is_Alias) {
+ Identifier($_->{to});
+ } else {
+ $_;
+ }
+ } @inside_select_list;
+
+ return (
+ inside_select_list => \@inside_select_list,
+ outside_select_list => \@outside_select_list,
+ default_inside_alias => $default_inside_alias,
+ );
+}
+
+sub _subquery_remap {
+ my ($self, $orig_select) = @_;
+
+ my $gensym_count;
+ my %select_remap = $self->_subquery_remap_select($orig_select);
+
+ my $default_inside_alias = $select_remap{default_inside_alias};
+ my @inside_select_list = @{$select_remap{inside_select_list}};
+ my @outside_select_list = @{$select_remap{outside_select_list}};
+
my %alias_map = map {
if (is_Alias and is_Identifier $_->{from}) {
+(join('.',@{$_->{from}{elements}}) => Identifier($_->{to}))
}
} @inside_select_list;
- my @outside_select_list = map {
- if (is_Alias) {
- Identifier($_->{to});
- } else {
- $_;
- }
- } @inside_select_list;
-
my @inside_order;
my $inner_body = do {
my $order = $orig_select->{from};