From: Peter Rabbitson Date: Mon, 3 May 2010 16:32:35 +0000 (+0000) Subject: Do not add TOP prefixes to queries already containing it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aca481d85207323845bc076e58d5de52f3a8458f;p=dbsrgits%2FDBIx-Class-Historic.git Do not add TOP prefixes to queries already containing it --- diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index ef09d49..38c615b 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -158,7 +158,11 @@ sub _select_args_to_query { # see if this is an ordered subquery my $attrs = $_[3]; - if ( scalar $self->_parse_order_by ($attrs->{order_by}) ) { + if ( + $sql !~ /^ \s* SELECT \s+ TOP \s+ \d+ \s+ /xi + && + scalar $self->_parse_order_by ($attrs->{order_by}) + ) { $self->throw_exception( 'An ordered subselect encountered - this is not safe! Please see "Ordered Subselects" in DBIx::Class::Storage::DBI::MSSQL ') unless $attrs->{unsafe_subselect_ok};