#1 2021-09-09 14:00:21

larand54
Member
Registered: 2018-12-25
Posts: 96

Error code: 406 fail on aggregate (ORM.add)

This happens when I use a class that have references to another class.
see below:

  TLogType = class(TSynPersistent)
    private
      fName: RawUTF8;
      fValue: integer;
    published
      property name: RawUTF8 read fName write fName;
      property value: integer read fValue write fValue;
  end;
  TLogTypeObjArray = array of TLogtype;


  TMyLog = class(TSynpersistent)
    private
      fLogdate: TDate;
      fComment: RawUTF8;
      fLogType: TLogType;    <<<<-- the reference
    published
      property logDate: TDate read fLogDate write fLogDate;
      property comment: RawUTF8 read fComment write fComment;
      property logType: TLogType read fLogType write fLogType;
  end;

The reference is flattened in the TSQLRecord so the field "LogType" will be two fields:
LogType_Name" and "LogType_value".

Don't have a clue any longer how to solve this. I have a small zip file of a test project to share but don't know where to put it.
The exception occurs in a section called "fake interface" in the mORMot unit.

Would appreciate any help to solve this. Also, a site where I could upload my little zip file (12k).

Maybe this link? https://1drv.ms/u/s!AkzgaKIeNifrhLQze1G … A?e=ZCbpMx

Last edited by larand54 (2021-09-09 14:35:29)


Delphi-11, WIN10

Offline

#2 2021-09-10 14:08:38

trx
Member
Registered: 2015-08-30
Posts: 30

Re: Error code: 406 fail on aggregate (ORM.add)

Hi,

You haven't initialized fLogType. Try using TSynAutoCreateFields as the base class of TMyLog and remove the write part of the logType property.

TMyLog = class(TSynAutoCreateFields)
    private
      fLogdate: TDate;
      fComment: RawUTF8;
      fLogType: TLogType;
    published
      property logDate: TDate read fLogDate write fLogDate;
      property comment: RawUTF8 read fComment write fComment;
      property logType: TLogType read fLogType;
  end;

For the TSQLRecord properties, you have flattened them propertly, but make sure to use the same letter casing.
For example logType.name should be logType_name and not LogType_Name.

Offline

#3 2021-09-13 17:17:34

larand54
Member
Registered: 2018-12-25
Posts: 96

Re: Error code: 406 fail on aggregate (ORM.add)

Ok, thanks.
Yes, the problem was that I didn't use "TSynAutoCreateFields". After changing that, all is now well.


Delphi-11, WIN10

Offline

Board footer

Powered by FluxBB