implement FIRST ? SKIP ?
Matt S Trout [Sun, 6 May 2012 23:25:01 +0000 (23:25 +0000)]
lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm [new file with mode: 0644]

diff --git a/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm b/lib/Data/Query/Renderer/SQL/Slice/FirstSkip.pm
new file mode 100644 (file)
index 0000000..c085a1d
--- /dev/null
@@ -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;