#1 2018-12-18 11:14:19

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Possible errors found in mORMot Documentation

Hello,

I'm reading the documentation page and here, I intend to post any possible errors I find.

4.4.1.2. Variant array documents

The code sample of pseudo methods has the following possible errors:

Line 4:

writeln(V1.Value(i),':',V2._(i));

fires EVariantError exception, I presume the correct version is:

writeln(V1.Value(i),':',V1._(i));

Line 9:

if V1.Exists('John') then

fires EDocVariant exception, while the following change passes:

if V2.Exists('name') then

It seems that the Exists pseudo method can't search for a value in array but can search an object property instead. Both examples are tested with Delphi 10.3 Community and Lazarus 1.9.0/FPC 3.1.1 in Windows 7 64bit.

In the last sample code of the paragraph, the following lines produce compile errors ([dcc32 Error] Project1.dpr(29): E2054 Illegal type in Write/Writeln statement in Delphi 10.3, project2.lpr(98,24) Error: Can't read or write variables of this type in FPC).

writeln(Doc.A['test']);
...
writeln(Doc.A['test']);

If you comment out them, the sample compiles and runs successfully.

Last edited by damiand (2018-12-18 11:49:28)

Offline

#2 2018-12-19 10:36:52

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Re: Possible errors found in mORMot Documentation

4.4.1.3. Create variant object or array documents from JSON

In the code example, line:

V3 := _Json('{"name":?,"year":?}',[],['john',1982]);

should be changed to:

V3 := _JsonFmt('{"name":?,"year":?}',[],['john',1982]);

By the way, TDocVariant documents are not displayed as strings in Lazarus/FPC debugger watch. The following error is displayed in the variable watch window instead:

unsupported variant type: TFMTBcdFactory

Is there any workaround?

Last edited by damiand (2018-12-19 11:00:31)

Offline

Board footer

Powered by FluxBB