Skip to content
Permalink
Browse files

Issue #12: Fix TDBConnection.ApplyLimitClause for SQLite, which does …

…not support a LIMIT clause in UPDATE/DELETE statements
  • Loading branch information
ansgarbecker committed Jan 1, 2020
1 parent 5269236 commit 01b37b64735c95bcf56eac812632c975704bc6af
Showing with 12 additions and 1 deletion.
  1. +12 −1 source/dbconnection.pas
@@ -6090,7 +6090,7 @@ function TDBConnection.ApplyLimitClause(QueryType, QueryBody: String; Limit, Off
Result := Result + 'TOP '+IntToStr(Limit)+' ';
Result := Result + QueryBody;
end;
ngMySQL, ngSQLite: begin
ngMySQL: begin
Result := Result + QueryBody + ' LIMIT ';
if Offset > 0 then
Result := Result + IntToStr(Offset) + ', ';
@@ -6104,6 +6104,17 @@ function TDBConnection.ApplyLimitClause(QueryType, QueryBody: String; Limit, Off
end else
Result := Result + QueryBody;
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;

0 comments on commit 01b37b6

Please sign in to comment.
You can’t perform that action at this time.