[Bast-commits] r8127 - DBIx-Class/0.08/branches/mssql_limit_regression/lib/DBIx/Class/Storage/DBI

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Wed Dec 16 10:47:49 GMT 2009


Author: ribasushi
Date: 2009-12-16 10:47:48 +0000 (Wed, 16 Dec 2009)
New Revision: 8127

Modified:
   DBIx-Class/0.08/branches/mssql_limit_regression/lib/DBIx/Class/Storage/DBI/MSSQL.pm
Log:
This is horrific but the tests pass... maybe someone will figure out something better

Modified: DBIx-Class/0.08/branches/mssql_limit_regression/lib/DBIx/Class/Storage/DBI/MSSQL.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_limit_regression/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2009-12-16 10:29:20 UTC (rev 8126)
+++ DBIx-Class/0.08/branches/mssql_limit_regression/lib/DBIx/Class/Storage/DBI/MSSQL.pm	2009-12-16 10:47:48 UTC (rev 8127)
@@ -179,8 +179,9 @@
 sub last_insert_id { shift->_identity }
 
 #
-# MSSQL is retarded wrt ordered subselects. One needs to add a TOP 100%
-# to *all* subqueries, do it here.
+# MSSQL is retarded wrt ordered subselects. One needs to add a TOP
+# to *all* subqueries, but one also can't use TOP 100 PERCENT
+# http://sqladvice.com/forums/permalink/18496/22931/ShowThread.aspx#22931
 #
 sub _select_args_to_query {
   my $self = shift;
@@ -190,7 +191,8 @@
   # see if this is an ordered subquery
   my $attrs = $_[3];
   if ( scalar $self->sql_maker->_order_by_chunks ($attrs->{order_by}) ) {
-    $sql =~ s/^ \s* SELECT \s/SELECT TOP 100 PERCENT /xi;
+    my $max = 2 ** 32;
+    $sql =~ s/^ \s* SELECT \s/SELECT TOP $max /xi;
   }
 
   return wantarray




More information about the Bast-commits mailing list