Skip to content

Commit 24b80ba

Browse files
fix: read SQLite BLOB columns via sqlite3_column_blob instead of truncated text
Refs #1980 Co-authored-by: ansgarbecker <ansgarbecker@users.noreply.github.com>
1 parent 707543c commit 24b80ba

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎source/dbconnection.pas‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,7 +3809,8 @@ procedure TSQLiteConnection.Query(SQL: String; DoStoreResult: Boolean=False; Log
38093809
Value: TGridValue;
38103810
QueryResult: Psqlite3_stmt;
38113811
QueryStatus: Integer;
3812-
i, OldRowsAffected: Integer;
3812+
i, NumBytes, OldRowsAffected: Integer;
3813+
AnsiStr: AnsiString;
38133814
CurrentSQL, NextSQL: PAnsiChar;
38143815
StepResult: Integer;
38153816
begin
@@ -3841,8 +3842,15 @@ procedure TSQLiteConnection.Query(SQL: String; DoStoreResult: Boolean=False; Log
38413842
Row := TGridRow.Create;
38423843
for i:=0 to FLib.sqlite3_column_count(QueryResult)-1 do begin
38433844
Value := TGridValue.Create;
3844-
Value.OldText := DecodeAPIString(FLib.sqlite3_column_text(QueryResult, i));
3845-
Value.OldIsNull := FLib.sqlite3_column_text(QueryResult, i) = nil;
3845+
if FLib.sqlite3_column_type(QueryResult, i) = SQLITE_BLOB then begin
3846+
NumBytes := FLib.sqlite3_column_bytes(QueryResult, i);
3847+
SetString(AnsiStr, PAnsiChar(FLib.sqlite3_column_blob(QueryResult, i)), NumBytes);
3848+
Value.OldText := String(AnsiStr);
3849+
Value.OldIsNull := False;
3850+
end else begin
3851+
Value.OldText := DecodeAPIString(FLib.sqlite3_column_text(QueryResult, i));
3852+
Value.OldIsNull := FLib.sqlite3_column_text(QueryResult, i) = nil;
3853+
end;
38463854
Row.Add(Value);
38473855
end;
38483856
Rows.Add(Row);

0 commit comments

Comments
 (0)