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;
