Skip to content

Commit

Permalink
Merge pull request #458 from muuvmuuv/bugfix/order-of-distinct-421
Browse files Browse the repository at this point in the history
Fix placement of distinct in sqlsrv limit
  • Loading branch information
develart-projects authored Oct 29, 2024
2 parents 68d83e1 + cc71890 commit 9d88eb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Db/Adapter/Sqlsrv.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public function limit($sql, $count, $offset = 0)
}

if ($offset === 0) {
$sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
$sql = preg_replace('/^SELECT(\s+DISTINCT)?\s/i', 'SELECT$1 TOP ' . $count . ' ', $sql);
} else {
$orderby = stristr($sql, 'ORDER BY');

Expand Down

0 comments on commit 9d88eb8

Please sign in to comment.