From: Peter Rabbitson Date: Wed, 16 Dec 2009 10:47:48 +0000 (+0000) Subject: This is horrific but the tests pass... maybe someone will figure out something better X-Git-Tag: v0.08116~61^2~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e74c68ce64d8fd3c4838ebd8de8d5b580167fa08;p=dbsrgits%2FDBIx-Class.git This is horrific but the tests pass... maybe someone will figure out something better --- diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index cc831e8..178a007 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -179,8 +179,9 @@ sub _execute { 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 @@ sub _select_args_to_query { # 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