Skip to content

Commit 6e10d52

Browse files
committed
fix!: SQLSRV _limit(0)
1 parent 46a0f05 commit 6e10d52

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

system/Database/SQLSRV/Builder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ private function addIdentity(string $fullTable, string $insert): string
306306
*/
307307
protected function _limit(string $sql, bool $offsetIgnore = false): string
308308
{
309+
// SQL Server cannot handle `LIMIT 0`.
310+
// DatabaseException:
311+
// [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The number of
312+
// rows provided for a FETCH clause must be greater then zero.
313+
if ($this->QBLimit === 0) {
314+
return $sql . ' WHERE 1=0 ';
315+
}
316+
309317
if (empty($this->QBOrderBy)) {
310318
$sql .= ' ORDER BY (SELECT NULL) ';
311319
}

0 commit comments

Comments
 (0)