From: Peter Rabbitson Date: Mon, 2 Feb 2009 17:38:16 +0000 (+0000) Subject: Bring back _RowNumberOver deleted in the sqla commotion (revs: 5096,5322,5383) X-Git-Tag: v0.08240~149 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=635a02ba4161a321d876d5fb918d862cc3e32a61;p=dbsrgits%2FDBIx-Class.git Bring back _RowNumberOver deleted in the sqla commotion (revs: 5096,5322,5383) --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 5bafd7c..014deee 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -50,6 +50,29 @@ sub new { $self; } +sub _RowNumberOver { + my ($self, $sql, $order, $rows, $offset ) = @_; + + $offset += 1; + my $last = $rows + $offset; + my ( $order_by ) = $self->_order_by( $order ); + + $sql = <<'SQL'; +SELECT * FROM +( + SELECT Q1.*, ROW_NUMBER() OVER( ) AS ROW_NUM FROM ( + $sql + $order_by + ) Q1 +) Q2 +WHERE ROW_NUM BETWEEN $offset AND $last + +SQL + + return $sql; +} + + # While we're at it, this should make LIMIT queries more efficient, # without digging into things too deeply use Scalar::Util 'blessed';