#1 2021-10-11 10:48:18

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Using RTTI and GetValue/SetValue with empty UTF8String Prop

Hi,

I believe I finally have made it down to the problem, that is arising.

Now there are basically two possibilities for my problem:

a) (likely) - me using TRttiCustom incorrectly
b) something in the handling of empty UTF8String-properties

The full sample is at: https://pastebin.com/ENbYBjm4

When ran as show, it will throw an exception when using SetValue.
To NOT see the exception, set Source.Field_01 to anything, BUT an empty string.

Fun fact: i have about 50 regression tests against my Domain-ORM-mapper with various data, incl. empty strings, all of them succeeded. However, this simple sample crashed.
Added it to my tests now as well and hoping to learn more about my problem.

Regards
Daniel

P.S: Tested on Delphi 10.4.2 and Delphi 11.0 - Win32

Last edited by sakura (2021-10-11 10:50:30)

Offline

#2 2021-10-11 16:40:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Using RTTI and GetValue/SetValue with empty UTF8String Prop

You are indeed using low-level RTTI code, which may be confusing to use.
It was designed for the particular use of mORMot RTTI internals.
Those GetValue/SetValue are used only in some border-case by our unit, when a getter or a setter are needed. So they are not fully tested, in all possible cases.  See for instance how TRttiCustomProps.CopyProperties is implemented.
So it appears that you found a bug. sad

It should be fixed now with my latest commit. The void string is now passed as varByRef, as it should.
I am very sorry for the inconvenience.

Offline

#3 2021-10-11 18:01:56

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 239
Website

Re: Using RTTI and GetValue/SetValue with empty UTF8String Prop

It looks great - and thank YOU, bugs come with software, it is just strange how this came up, rather with that update, actually not related to it...
I'll take a close look at CopyProperties tomorrow :-)

Thanks again,
Daniel

Offline

Board footer

Powered by FluxBB