From: Matt S Trout Date: Fri, 1 Nov 2013 01:42:56 +0000 (+0000) Subject: use more DQ in DBIHacks to avoid literals everywhere X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e706b4ba26c096be20ed78e1af27de0acd6333f;p=dbsrgits%2FDBIx-Class.git use more DQ in DBIHacks to avoid literals everywhere --- diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index ab49ec6..9e5d5ac 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -260,11 +260,11 @@ sub _adjust_select_args_for_complex_prefetch { # everything is a literal at this point, since we are likely properly # quoted and stuff while (is_Order($order_dq)) { - my ($chunk, @args) = $sql_maker->_render_dq($order_dq->{by}); + my ($chunk, @args) = $sql_maker->_render_dq(my $by = $order_dq->{by}); my $is_desc = $order_dq->{reverse}; - push @new_order, \[ $chunk.($is_desc ? ' DESC' : ''), @args ]; + push @new_order, $is_desc ? { -desc => \$by } : \$by; $order_dq = $order_dq->{from}; @@ -284,12 +284,13 @@ sub _adjust_select_args_for_complex_prefetch { $inner_columns_info->{$ord_bit}{-source_alias} eq $root_alias ); - $new_order[-1] = \[ + ($new_order[-1]) = map { + ($is_desc ? { -desc => $_ } : $_) + } \[ sprintf( - '%s(%s)%s', + '%s(%s)', ($is_desc ? 'MAX' : 'MIN'), $chunk, - ($is_desc ? ' DESC' : ''), ), @args ];