You are not logged in.
Pages: 1
Hello,
I have problem when I'm trying to call service function via interfaces. When function has record param, then Access Violation is raised while executing. After small investigation I found where exists the problem. The problem occurs while serializing record parameter. I wrote small demo example:
type
TTestRecord = record
Int: Integer;
Bool: Boolean;
Text: String;
end;
procedure Test;
var
tw: TTextWriter;
rec: TTestRecord;
stream: TStream;
begin
stream := TMemoryStream.Create;
try
tw := TTextWriter.Create(stream);
tw.AddRecordJSON(rec, TypeInfo(TTestRecord));
finally
stream.Free;
end;
end;
The Access Violation exception is raised in line: tw.AddRecordJSON(rec, TypeInfo(TTestRecord));
But if definition of the record is changed to:
TTestRecord = record
Int: Integer;
Text: String;
Bool: Boolean;
end;
then everything works correctly. I'm using Delphi XE4Pro, and current version of mORMot.
best regards
Adam Siwon
best regards
Adam Siwon
Offline
Hello,
thank you very much. Now it works as expected. It would be nice to add this information to the documentation. In sections 10.1.3. Record serialization and 10.1.3.1. Automatic serialization via Enhanced RTTI there is no direct information about this requirement.
best regards
Adam Siwon
Last edited by ASiwon (2015-02-05 22:19:35)
best regards
Adam Siwon
Offline
It is written everywhere in the documentation.
Every record in the documentation is defined as "= packed record".
But it was not clear enough.
I've updated the documentation.
Thanks for the feedback.
Offline
Please do not be angry with me. mORMot documentation is really huge and sometime I have problem to find required information.
I have another documentation related question. In section 5.3.1. Return a list of objects exists example:
var aList: TObjectList<TSQLBaby>;
aMale: TSQLBaby;
...
aList := Client.RetrieveObjectList<TSQLBaby>('Name LIKE ? AND Sex = ?' ,['A%' ,ord(sMale)]);
try
for aMale in aList do
DoSomethingWith(aMale);
finally
aList.Free;
end;
But in mORMot code function RetrieveObjectList doesn't exists. I think this line in example should looks like:
aList := Client.RetrieveList<TSQLBaby>('Name LIKE ? AND Sex = ?' ,['A%' ,ord(sMale)]);
best regards
Adam Siwon
best regards
Adam Siwon
Offline
No problem Adam - on the contrary, any feedback about the documentation is worth telling!
It is difficult to reflect all the API changes in real-time, without introducing any error.
Most of the API is generated from the sources, so should be almost accurate, but the high level presentation code needs to be proven by hand.
Should be fixed by http://synopse.info/fossil/info/4a18c1883f
Thanks for the feedback.
Offline
Pages: 1