From: Matt S Trout Date: Sat, 28 Jul 2012 11:38:59 +0000 (+0000) Subject: fix expr.include to generate alias nodes correctly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4b25214a381450e4ef5f9e411a1ba26efd026fc;p=dbsrgits%2FData-Query.git fix expr.include to generate alias nodes correctly --- diff --git a/lib/Data/Query/Renderer/SQL/Slice/GenericSubQ.pm b/lib/Data/Query/Renderer/SQL/Slice/GenericSubQ.pm index 92379af..f912f61 100644 --- a/lib/Data/Query/Renderer/SQL/Slice/GenericSubQ.pm +++ b/lib/Data/Query/Renderer/SQL/Slice/GenericSubQ.pm @@ -129,7 +129,11 @@ sub _render_slice { where => { type => DQ_OPERATOR, operator => { - 'SQL.Naive' => $dq->{offset} ? 'BETWEEN' : '<' + 'SQL.Naive' => ( + $dq->{offset} + ? 'BETWEEN' + : $order_nodes[0]{reverse} ? '>' : '<' + ), }, args => [ { @@ -159,7 +163,9 @@ sub _render_slice { }, where => { type => DQ_OPERATOR, - operator => { 'SQL.Naive' => '<' }, + operator => { + 'SQL.Naive' => $order_nodes[0]{reverse} ? '>' : '<' + }, args => [ map +{ type => DQ_IDENTIFIER, @@ -172,8 +178,14 @@ sub _render_slice { } }, }, - $dq->{limit}, - ($dq->{offset} ? ($dq->{offset} : ())), + ($dq->{offset} + ? ($dq->{offset}, + { %{$dq->{limit}}, + value => $dq->{offset}{value} + $dq->{limit}{value} - 1 + } + ) + : ($dq->{limit}) + ), ] }, }; diff --git a/t/expr.include b/t/expr.include index beaff7c..6d80c9d 100644 --- a/t/expr.include +++ b/t/expr.include @@ -34,8 +34,8 @@ sub SELECT (&;@) { (ref($select[0]) eq 'LIES::AS' ? +{ type => DQ_ALIAS, - alias => $e->{expr}, - as => ${shift(@select)} + from => $e->{expr}, + to => ${shift(@select)} } : $e->{expr} );