X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=178a0079698d8b39457b41978b7d4c78742104bb;hb=25efdc9bcfd25ac45199b779498b37c02d6847a3;hp=cc831e8f93acbd3475398ba870a77680ab21946a;hpb=097c51673186a12c2c216b19aeb464fba088bdbb;p=dbsrgits%2FDBIx-Class-Historic.git 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