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]
];