You are not logged in.
Pages: 1
Overloaded TSQLRest.Add with SimpleFields array writes blank dates to database :
type
TTestRec = class(TSQLRecord)
private
FDatePosted : TDateTime;
published
property DatePosted : TDateTime read FDatePosted write FDatePosted;
end;
...
TestRec := TTestRec.Create;
try
TestRec.DatePosted := Now;
Client.Add(TestRec,true) // will insert current time
finally
TestRec.Free;
end;
...
Client.Add(TTestRec,[Now]) // will insert MinDateTime
Client.Add(TTestRec,[DateTimeToIso8601(Now,true)]) // will insert current time
Seems that TSQLRecord.SimplePropertiesFill (actually VarRecToUTF8()) cannot distinguish TDateTime from Double and TSQLPropInfoRTTIDateTime.SetValue is calling Iso8601ToDateTimePUTF8CharVar with floating-point representation of TDateTime.
Maybe if we pass TSQLRecordClass to TSQLRecord.SimplePropertiesFill as second parameter we could distinguish TDateTime from Double using TSQLRecordClass ?
Offline
This is a limitation of "array of const" implementation in Delphi.
It can not distinguish TDateTime from Double.
Using DateTimeToIso8601() is a good workaround.
Note that you can use TModTime or TCreateTime auto-filled fields instead, if you need a field which contains the modification/creation row timestamp.
Offline
Pages: 1