From: Peter Rabbitson Date: Mon, 2 Feb 2009 17:52:20 +0000 (+0000) Subject: part 2 X-Git-Tag: v0.08240~148 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f1a22401841399be21d55b0f64fac01288238bd4;p=dbsrgits%2FDBIx-Class.git part 2 --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 014deee..c8d2840 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -50,6 +50,9 @@ sub new { $self; } +# DB2 is the only remaining DB using this. Even though we are not sure if +# RowNumberOver is still needed here (should be part of SQLA) leave the +# code in place sub _RowNumberOver { my ($self, $sql, $order, $rows, $offset ) = @_; @@ -57,7 +60,7 @@ sub _RowNumberOver { my $last = $rows + $offset; my ( $order_by ) = $self->_order_by( $order ); - $sql = <<'SQL'; + $sql = <<"SQL"; SELECT * FROM ( SELECT Q1.*, ROW_NUMBER() OVER( ) AS ROW_NUM FROM ( @@ -78,6 +81,15 @@ SQL use Scalar::Util 'blessed'; sub _find_syntax { my ($self, $syntax) = @_; + + # DB2 is the only remaining DB using this. Even though we are not sure if + # RowNumberOver is still needed here (should be part of SQLA) leave the + # code in place + my $dbhname = blessed($syntax) ? $syntax->{Driver}{Name} : $syntax; + if(ref($self) && $dbhname && $dbhname eq 'DB2') { + return 'RowNumberOver'; + } + $self->{_cached_syntax} ||= $self->SUPER::_find_syntax($syntax); }