[Bast-commits] r8038 - in DBIx-Class/0.08/branches/mssql_rno_pagination: . lib/DBIx/Class lib/DBIx/Class/SQLAHacks lib/DBIx/Class/Storage/DBI

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Fri Dec 4 14:06:11 GMT 2009


Author: ribasushi
Date: 2009-12-04 14:06:11 +0000 (Fri, 04 Dec 2009)
New Revision: 8038

Removed:
   DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks/MSSQL.pm
Modified:
   DBIx-Class/0.08/branches/mssql_rno_pagination/Makefile.PL
   DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm
Log:
Unify the MSSQL and DB2 RNO implementations - they are the same

Modified: DBIx-Class/0.08/branches/mssql_rno_pagination/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/mssql_rno_pagination/Makefile.PL	2009-12-04 14:01:32 UTC (rev 8037)
+++ DBIx-Class/0.08/branches/mssql_rno_pagination/Makefile.PL	2009-12-04 14:06:11 UTC (rev 8038)
@@ -143,7 +143,7 @@
 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
 
 no_index 'DBIx::Class::SQLAHacks';
-no_index 'DBIx::Class::SQLAHacks::MSSQL';
+no_index 'DBIx::Class::SQLAHacks::MySQL';
 no_index 'DBIx::Class::SQLAHacks::OracleJoins';
 no_index 'DBIx::Class::Storage::DBI::AmbiguousGlob';
 no_index 'DBIx::Class::Storage::DBIHacks';

Deleted: DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks/MSSQL.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks/MSSQL.pm	2009-12-04 14:01:32 UTC (rev 8037)
+++ DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks/MSSQL.pm	2009-12-04 14:06:11 UTC (rev 8038)
@@ -1,36 +0,0 @@
-package # Hide from PAUSE
-  DBIx::Class::SQLAHacks::MSSQL;
-
-use warnings;
-use strict;
-
-use base qw( DBIx::Class::SQLAHacks );
-use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
-
-# an MSSQL-specific implementation of the Row-Number-Over limiting
-# technique
-
-sub _MSRowNumberOver {
-  my ($self, $sql, $order, $rows, $offset ) = @_;
-
-  # get the order_by only (or make up an order if none exists)
-  my $order_by = $self->_order_by(
-    (delete $order->{order_by}) || \ '(SELECT (1))'
-  );
-
-  # whatever is left
-  my $group_having = $self->_order_by($order);
-
-  $sql = sprintf (<<'EOS', $order_by, $sql, $group_having, $offset + 1, $offset + $rows, );
-
-SELECT * FROM (
-  SELECT orig_query.*, ROW_NUMBER() OVER(%s ) AS rno__row__index FROM (%s%s) orig_query
-) rno_subq WHERE rno__row__index BETWEEN %d AND %d
-
-EOS
-
-  $sql =~ s/\s*\n\s*/ /g;   # easier to read in the debugger
-  return $sql;
-}
-
-1;

Modified: DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks.pm	2009-12-04 14:01:32 UTC (rev 8037)
+++ DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/SQLAHacks.pm	2009-12-04 14:06:11 UTC (rev 8038)
@@ -47,31 +47,31 @@
 }
 
 
-# Slow but ANSI standard Limit/Offset support. DB2 uses this
+# ANSI standard Limit/Offset implementation. DB2 and MSSQL use this
 sub _RowNumberOver {
   my ($self, $sql, $order, $rows, $offset ) = @_;
 
-  $offset += 1;
-  my $last = $rows + $offset - 1;
-  my ( $order_by ) = $self->_order_by( $order );
+  # get the order_by only (or make up an order if none exists)
+  my $order_by = $self->_order_by(
+    (delete $order->{order_by}) || \ '(SELECT (1))'
+  );
 
-  $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
+  # whatever is left
+  my $group_having = $self->_order_by($order);
 
-SQL
+  $sql = sprintf (<<'EOS', $order_by, $sql, $group_having, $offset + 1, $offset + $rows, );
 
+SELECT * FROM (
+  SELECT orig_query.*, ROW_NUMBER() OVER(%s ) AS rno__row__index FROM (%s%s) orig_query
+) rno_subq WHERE rno__row__index BETWEEN %d AND %d
+
+EOS
+
+  $sql =~ s/\s*\n\s*/ /g;   # easier to read in the debugger
   return $sql;
 }
 
-# Crappy Top based Limit/Offset support. MSSQL uses this currently,
-# but may have to switch to RowNumberOver one day
+# Crappy Top based Limit/Offset support. Legacy from MSSQL.
 sub _Top {
   my ( $self, $sql, $order, $rows, $offset ) = @_;
 

Modified: DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2009-12-04 14:01:32 UTC (rev 8037)
+++ DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2009-12-04 14:06:11 UTC (rev 8038)
@@ -247,7 +247,7 @@
     $self->{_sql_maker_opts} = { %$opts };
   }
 
-  return { limit_dialect => 'MSRowNumberOver', %{$self->{_sql_maker_opts}||{}} };
+  return { limit_dialect => 'RowNumberOver', %{$self->{_sql_maker_opts}||{}} };
 }
 
 1;




More information about the Bast-commits mailing list