From: Matt S Trout Date: Sun, 6 May 2012 23:58:32 +0000 (+0000) Subject: FIRST ? SKIP ? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=119e511bed25c51b7414d071eff57fba747eb1d3;p=dbsrgits%2FData-Query.git FIRST ? SKIP ? --- diff --git a/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm b/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm index c085a1d..f6cd6dd 100644 --- a/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm +++ b/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm @@ -3,18 +3,20 @@ package Data::Query::Renderer::SQL::Slice::FirstSkip; use Moo::Role; use Data::Query::Constants qw(DQ_SLICE); +my %handle = (limit => 'FIRST', offset => 'SKIP'); + +sub _slice_order { qw(limit offset) } + sub _render_slice { my ($self, $dq) = @_; my $basic = $self->_render($dq->{from}); return [ $basic->[0], # SELECT keyword - ($dq->{limit} - ? ($self->_format_keyword('FIRST'), $self->_render($dq->{limit})) - : () - ), - ($dq->{offset} - ? ($self->_format_keyword('SKIP'), $self->_render($dq->{offset})) - : () + (map +( + $dq->{$_} + ? ($self->_format_keyword($handle{$_}), $self->_render($dq->{$_})) + : () + ), $self->_slice_order ), @{$basic}[1..$#$basic] ];