# Whatever order bindvals there are, they will be realiased and
# reselected, and need to show up at end of the initial inner select
push @{$self->{select_bind}}, @{$self->{order_bind}};
-
- # if this is a part of something bigger, we need to add back all
- # the extra order_by's, as they may be relied upon by the outside
- # of a prefetch or something
- if ($rs_attrs->{_is_internal_subuery}) {
- $sq_attrs->{selection_outer} .= sprintf ", $extra_order_sel->{$_} AS $_"
- for sort
- { $extra_order_sel->{$a} cmp $extra_order_sel->{$b} }
- grep { $_ !~ /[^\w\-]/ } # ignore functions
- keys %$extra_order_sel
- ;
- }
}
# and this is order re-alias magic
my $outer_attrs = { %$attrs };
delete $outer_attrs->{$_} for qw/where bind rows offset group_by having/;
- my $inner_attrs = { %$attrs, _is_internal_subuery => 1 };
+ my $inner_attrs = { %$attrs };
delete $inner_attrs->{$_} for qw/for collapse _prefetch_selector_range select as/;
# if the user did not request it, there is no point using it inside
$books_45_and_owners->search ({}, { group_by => 'title', order_by => 'title' })->as_query,
'(SELECT me.id, me.source, me.owner, me.price, owner.id, owner.name
FROM (
- SELECT me.id, me.source, me.owner, me.price, ORDER__BY__001 AS title
+ SELECT me.id, me.source, me.owner, me.price
FROM (
SELECT me.id, me.source, me.owner, me.price, ORDER__BY__001
FROM (
$books_45_and_owners->search ({}, { group_by => 'title', order_by => 'title' })->as_query,
'(SELECT me.id, me.source, me.owner, me.price, owner.id, owner.name
FROM (
- SELECT me.id, me.source, me.owner, me.price, ORDER__BY__001 AS title
+ SELECT me.id, me.source, me.owner, me.price
FROM (
SELECT TOP 2
me.id, me.source, me.owner, me.price, ORDER__BY__001