Dear coders,
I think I found a fix for a problem (?) in the function SetParamFromData below.
The problem is that when one has a json null in D:TJSONData, the procedure will raise an exception and halt the post for the record. See the comments below in the code for further explanation.
This is the link to the trunk:
https://svn.freepascal.org/svn/fpc/trunk/packages/fcl-web/src/restbridge/sqldbrestdata.pp so you can check the original code.
Is this an advisable and acceptable change?
Best regards
Simone Giacomelli
[code=pascal]
procedure TSQLDBRestDBHandler.SetParamFromData(P: TParam; F:
TSQLDBRestField;
D: TJSONData);
Var
S : String;
begin
// if Assigned(D) then // <-------
// S:=D.AsString; // <------- if it's JSON null it will raise an
exception
if not Assigned(D) or D.IsNull then // <------- added "D.IsNull" because
of JSON null
P.Clear
else if Assigned(F) then
Case F.FieldType of
rftInteger : P.AsInteger:=D.AsInteger;
rftLargeInt : P.AsLargeInt:=D.AsInt64;
rftFloat : P.AsFloat:=D.AsFloat;
rftDate :
P.AsDateTime:=ScanDateTime(GetString(rpDateFormat),D.AsString);
rftTime :
P.AsDateTime:=ScanDateTime(GetString(rpTimeFormat),D.AsString);
rftDateTime :
P.AsDateTime:=ScanDateTime(GetString(rpDateTimeFormat),D.AsString);
rftString : P.AsString:=D.AsString;
rftBoolean : P.AsBoolean:=D.AsBoolean;
rftBlob :
{$IFNDEF VER3_0}
P.AsBlob:=BytesOf(DecodeStringBase64(D.AsString));
{$ELSE}
P.AsBlob:=DecodeStringBase64(D.AsString);
{$ENDIF}
else
P.AsString:=D.AsString;
end
else
P.AsString:=D.AsString;
end;[/code]
