From: Matt S Trout Date: Sun, 6 May 2012 23:25:01 +0000 (+0000) Subject: implement FIRST ? SKIP ? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=623b3897849540e06aa3b3373b66259711cde67a;p=dbsrgits%2FData-Query.git implement FIRST ? SKIP ? --- diff --git a/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm b/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm new file mode 100644 index 0000000..c085a1d --- /dev/null +++ b/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm @@ -0,0 +1,23 @@ +package Data::Query::Renderer::SQL::Slice::FirstSkip; + +use Moo::Role; +use Data::Query::Constants qw(DQ_SLICE); + +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})) + : () + ), + @{$basic}[1..$#$basic] + ]; +}; + +1;