Jira issue originally created by user mklocke:
The function doModifyLimitQuery() in Doctrine\DBAL\Platforms\SQLServerPlatform does work correctly.
It removes the user generated ORDER BY (gets moved to OVER clause), but does not apply an ORDER BY on the row number created with ROW_NUMBER().
$orderBy = stristr($query, 'ORDER BY');
//Remove ORDER BY from $query (including nested parentheses in order by list).
$query = preg_replace('/\s<ins>ORDER\s</ins>BY\s<ins>([<sup>()]</ins>](\((?:(?:(?>[</sup>())<ins>)|(?R))*)\))</ins>/i', '', $query);
$format = 'SELECT * FROM (%s) AS doctrine*tbl WHERE doctrine*rownum BETWEEN %d AND %d';
The last format string should be:
$format = 'SELECT * FROM (%s) AS doctrine*tbl WHERE doctrine_rownum BETWEEN %d AND %d ORDER BY doctrine*rownum';
Comment created by @ocramius:
Possible relation with DBAL-927
Issue was closed with resolution "Fixed"
Comment created by @deeky666:
Fixed as of 040d49c