mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-26 14:50:16 +02:00
* Fix TBinaryField.Get/setAsBytes
This commit is contained in:
parent
d77f936d0e
commit
3d687576c6
@ -649,6 +649,8 @@ type
|
|||||||
function GetValue(var AValue: TBytes): Boolean;
|
function GetValue(var AValue: TBytes): Boolean;
|
||||||
procedure SetAsString(const AValue: string); override;
|
procedure SetAsString(const AValue: string); override;
|
||||||
procedure SetVarValue(const AValue: JSValue); override;
|
procedure SetVarValue(const AValue: JSValue); override;
|
||||||
|
Function GetAsBytes: TBytes; override;
|
||||||
|
Procedure SetAsBytes(const aValue: TBytes); override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@ -6922,7 +6924,7 @@ begin
|
|||||||
DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
|
DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TBinaryField.BlobToBytes(aValue : JSValue) : TBytes;
|
function TBinaryField.BlobToBytes(aValue: JSValue): TBytes;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(Dataset) then
|
if Assigned(Dataset) then
|
||||||
@ -6931,7 +6933,7 @@ begin
|
|||||||
Result:=TDataSet.DefaultBlobDataToBytes(aValue)
|
Result:=TDataSet.DefaultBlobDataToBytes(aValue)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TBinaryField.BytesToBlob(aValue : TBytes) : JSValue;
|
function TBinaryField.BytesToBlob(aValue: TBytes): JSValue;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(Dataset) then
|
if Assigned(Dataset) then
|
||||||
@ -6953,8 +6955,8 @@ begin
|
|||||||
if V<>Null then
|
if V<>Null then
|
||||||
begin
|
begin
|
||||||
S:=BlobToBytes(V);
|
S:=BlobToBytes(V);
|
||||||
For I:=0 to Length(S) do
|
For I:=0 to Length(S)-1 do
|
||||||
TJSString(Result).Concat(TJSString.fromCharCode(S[I]));
|
Result:=TJSString(Result).Concat(TJSString.fromCharCode(S[I]));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7015,6 +7017,24 @@ begin
|
|||||||
RaiseAccessError('Blob');
|
RaiseAccessError('Blob');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBinaryField.GetAsBytes: TBytes;
|
||||||
|
|
||||||
|
Var
|
||||||
|
V : JSValue;
|
||||||
|
|
||||||
|
begin
|
||||||
|
V:=GetData;
|
||||||
|
if Assigned(V) then
|
||||||
|
Result:=BlobToBytes(V)
|
||||||
|
else
|
||||||
|
SetLength(Result,0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBinaryField.SetAsBytes(const aValue: TBytes);
|
||||||
|
begin
|
||||||
|
SetData(BytesToBlob(aValue))
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor TBinaryField.Create(AOwner: TComponent);
|
constructor TBinaryField.Create(AOwner: TComponent);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user