Skip to content

Commit 4322372

Browse files
committed
fix: binary result values displayed as 000...
Refs #2276
1 parent 1c9321c commit 4322372

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

source/dbconnection.pas

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8941,22 +8941,31 @@ function TDBQuery.GetColBinData(Column: Integer; var baData: TBytes): Boolean;
89418941
function TMySQLQuery.GetColBinData(Column: Integer; var baData: TBytes): Boolean;
89428942
var
89438943
AnsiStr: AnsiString;
8944+
Len: Integer;
89448945
begin
89458946
Result := False;
89468947

89478948
if ColumnExists(Column) then begin
89488949
if FEditingPrepared and Assigned(FCurrentUpdateRow) then begin
89498950
// Row was edited and only valid in a TGridRow
89508951
AnsiStr := AnsiString(FCurrentUpdateRow[Column].NewText);
8952+
Len := Length(AnsiStr);
8953+
if Datatype(Column).Category in [dtcBinary, dtcSpatial] then begin
8954+
SetLength(baData, Len);
8955+
if Len > 0 then
8956+
Move(AnsiStr[1], baData[0], Len);
8957+
Result := True;
8958+
end;
89518959
end else begin
89528960
// The normal case: Fetch cell from mysql result
8953-
SetString(AnsiStr, FCurrentRow[Column], FColumnLengths[Column]);
8954-
end;
8955-
8956-
if Datatype(Column).Category in [dtcBinary, dtcSpatial] then begin
8957-
SetLength(baData, Length(AnsiStr));
8958-
//CopyMemory(baData, @AnsiStr[1], Length(AnsiStr));
8959-
Result := True;
8961+
Len := FColumnLengths[Column];
8962+
SetString(AnsiStr, FCurrentRow[Column], Len);
8963+
if Datatype(Column).Category in [dtcBinary, dtcSpatial] then begin
8964+
SetLength(baData, Len);
8965+
if Len > 0 then
8966+
Move(FCurrentRow[Column]^, baData[0], Len);
8967+
Result := True;
8968+
end;
89608969
end;
89618970
end;
89628971
end;

0 commit comments

Comments
 (0)