From: Matt S Trout Date: Fri, 20 Apr 2012 10:52:46 +0000 (+0000) Subject: fixup gensym behaviour X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1bfa648a7e86852c2a372dc4664d4f63d9e7317e;p=dbsrgits%2FData-Query.git fixup gensym behaviour --- diff --git a/lib/Data/Query/Renderer/SQL/Slice/FetchFirst.pm b/lib/Data/Query/Renderer/SQL/Slice/FetchFirst.pm index 6dd07fe..c45f836 100644 --- a/lib/Data/Query/Renderer/SQL/Slice/FetchFirst.pm +++ b/lib/Data/Query/Renderer/SQL/Slice/FetchFirst.pm @@ -46,7 +46,7 @@ sub _render_slice { } else { die "XXX not implemented yet"; } - $name ||= 'GENSYM__'.++$gensym_count; + $name ||= sprintf("GENSYM__%03i",++$gensym_count); push @inside_select_list, +{ type => DQ_ALIAS, from => $s, @@ -68,7 +68,7 @@ sub _render_slice { $order_map{$by} = $alias_map{join('.', @{$by->{elements}})} ||= do { - my $name = 'ORDER__BY__'.++$order_gensym_count; + my $name = sprintf("ORDER__BY__%03i",++$order_gensym_count); push @inside_select_list, +{ type => DQ_ALIAS, from => $by, @@ -121,7 +121,10 @@ sub _render_slice { type => DQ_SELECT, select => ( $dq->{preserve_order} - ? [ @outside_select_list, @order_map{map $_->{by}, @order_nodes} ] + ? [ + @outside_select_list, + grep @{$_->{elements}} == 1, @order_map{map $_->{by}, @order_nodes} + ] : \@outside_select_list, ), from => $outside_order,