You are not logged in.
Console application with Mormot2 connecting to the same Mysql server using RetrieveIList inside an REST Interface call
The code is the following:
var upedia:ilist<TOrmUFpedia>; upedio:TOrmUFpedia;
....
srv.Orm.RetrieveIList(TOrmUFpedia,upedia,'RowID,title,descr,opts');
for upedio in upedia do .....
TOrmUFpedia is declared as follows:
TOrmUFpedia = class(TOrm)
private
Ftitle, Fdescr, Fopts: utf8string;
function Getopts: utf8string;
procedure Setopts(const Value: utf8string);
public
cOpts:Dufoptions;
published
property title:utf8string index 500 read Ftitle write Ftitle;
property descr:utf8string index 500 read Fdescr write Fdescr;
property opts:utf8string read Getopts write Setopts;
end;
function TOrmUFpedia.Getopts: utf8string;
begin result:=RecordSaveJson(cOpts,typeinfo(Dufoptions)); end;
procedure TOrmUFpedia.Setopts(const Value: utf8string);
begin if (Value='') or (not RecordLoadJson(cOpts,value,typeinfo(Dufoptions))) then cOpts:=Default(Dufoptions); end;
where Dufoptions is a record
The code using the above is compiled by both Delphi 11.1 and FPC 3.2.0-r47409 [2022/04/01] for i386, all units are used the same, only project file is different
Compiled executable (32 & 64bit for FPC, 32bit for Delphi 11.1) runs using the same database Mysql 10.6.7
When I access the upedio.opts in for each loop as returned by RetrieveIList ...:
a) In Delphi 11.1, upedio.opts is returned OK
b) In FPC 3.2 I am getting a "DA4AAA==" as content
Does RecordLoadJson needs records like Dufoptions to be registered somehow in FPC ?
Offline
This is documented as such, due to FPC not having the RTTI for records, as Delphi does since Delphi 2010.
On FPC, you need to register the record definition as text at startup.
Check https://synopse.info/files/html/Synopse … ml#TITL_51
and https://synopse.info/files/html/Synopse … #TITLE_244
On mORMot 2, use TRttiJson.RegisterFromText() as registration method.
Offline
Thanks a lot. I though it was changed in last versions of FPC.
Offline
The latest FPC has supported RTTI record (https://gitlab.com/freepascal.org/fpc/s … sues/40798)
Request improvements to mormot2 DynArrayLoadJson in FPC.
Offline
About your
https://github.com/synopse/mORMot2/issues/266
I have added experimental support with
https://github.com/synopse/mORMot2/commit/c0dbef41
Feedback is welcome!
Offline
You're amazing. Everything is working on the new mormot2.
Offline