You are not logged in.
Pages: 1
Delphi 12 Athens, mORMot2 V2.2
Following test case:
type
TTestItem = record
Name1: String;
Name2: String;
end;
var
item: TTestItem;
begin
item.Name1 := 'A';
item.Name2 := 'B';
ShowMessage(Utf8ToString(RecordSaveJson(item, TypeInfo(TTestItem))));
All tests except for the last one are ok. This leads to an access violation:
Rtti.ByTypeInfo[TypeInfo(TTestItem)].Props.NameChange('Name1', ''); // Ok: {"Name2":"B"}
Rtti.ByTypeInfo[TypeInfo(TTestItem)].Props.NameChanges(['Name1'], ['']); // Ok: {"Name2":"B"}
Rtti.ByTypeInfo[TypeInfo(TTestItem)].Props.NameChanges(['Name1', 'Name2'], ['N1', 'N2']); // Ok: {"N1":"A","N2":"B"}
Rtti.ByTypeInfo[TypeInfo(TTestItem)].Props.NameChanges(['Name1', 'Name2'], ['N1', '']); // Ok: {"N1":"A"}
Rtti.ByTypeInfo[TypeInfo(TTestItem)].Props.NameChanges(['Name1', 'Name2'], ['', 'N2']); // Error: Access violation
With best regards
Thomas
Last edited by tbo (2024-01-09 18:26:38)
Offline
try
https://github.com/synopse/mORMot2/commit/6fe3a481
BTW I guess you should be able to write shorter:
Rtti[TypeInfo(TTestItem)].Props...
Offline
Pages: 1