};
my $order_gensym_count;
- my %order_map;
- foreach my $order (@order_nodes) {
- my $by = $order->{by};
+ my @mapped_order = map {
+ my $by = $_->{by};
if (is_Identifier $by) {
$default_inside_alias ||= $by->{elements}[0]
if @{$by->{elements}} == 2;
- $order_map{$by}
+ my $mapped_by
= $alias_map{join('.', @{$by->{elements}})}
||= do {
if (
Identifier($name);
}
};
+ Order($mapped_by, $_->{reverse});
} else {
die "XXX not implemented yet";
}
- }
+ } @order_nodes;
$default_inside_alias ||= 'me';
? Select(
\@outside_select_list,
compose {
- Order($order_map{$b->{by}}, $b->{reverse}, $a)
+ Order($b->{by}, $b->{reverse}, $a)
} (
- @order_nodes,
+ @mapped_order,
Alias($default_inside_alias, $_)
)
)
@outside_select_list,
$dq->{preserve_order}
? (grep @{$_->{elements}} == 1,
- @order_map{map $_->{by}, @order_nodes})
+ map $_->{by}, @mapped_order)
: (),
],
compose {
- Order($order_map{$b->{by}}, !$b->{reverse}, $a)
+ Order($b->{by}, !$b->{reverse}, $a)
} (
- @order_nodes,
+ @mapped_order,
Alias(
$default_inside_alias,
Slice(