Issue #12: Fix TDBConnection.ApplyLimitClause for SQLite, which does not support a LIMIT clause in UPDATE/DELETE statements

This commit is contained in:
Ansgar Becker
2020-01-01 11:53:52 +01:00
parent 52692367b6
commit 01b37b6473

View File

@ -6090,7 +6090,7 @@ begin
Result := Result + 'TOP '+IntToStr(Limit)+' '; Result := Result + 'TOP '+IntToStr(Limit)+' ';
Result := Result + QueryBody; Result := Result + QueryBody;
end; end;
ngMySQL, ngSQLite: begin ngMySQL: begin
Result := Result + QueryBody + ' LIMIT '; Result := Result + QueryBody + ' LIMIT ';
if Offset > 0 then if Offset > 0 then
Result := Result + IntToStr(Offset) + ', '; Result := Result + IntToStr(Offset) + ', ';
@ -6104,6 +6104,17 @@ begin
end else end else
Result := Result + QueryBody; Result := Result + QueryBody;
end; end;
ngSQLite: begin
// LIMIT supported only in SELECT queries
// For UPDATEs and DELETEs only if we would compile sqlite library with SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile flag
Result := Result + QueryBody;
if Result.StartsWith('SELECT') then begin
Result := Result + ' LIMIT ';
if Offset > 0 then
Result := Result + IntToStr(Offset) + ', ';
Result := Result + IntToStr(Limit);
end;
end;
end; end;
end; end;