#1 2018-05-16 14:02:57

ehkhalid
Member
Registered: 2018-05-16
Posts: 12

Record cannot be published under lazarus/FPC

Hi,

   First of all, thank you a lot for this great framework, really amazing work.

   I have a problem compiiling my project under lazarus/fpc targeting linux, my TsqlRecord which include a record property can't compile under fpc, i got an error indicate that record cannot be used as published property !
   
   I tried with the sample project 21 - http performance, i added a record property to the TSqlRecordPeople, and i got the same error.

   Maybe some missing RTTI, i tried FPC, new pascal and got the same error!

   Any solution  ?

type
  TTest = record
      name : RawUTF8;
  end;

  TSQLRecordPeople = class(TSQLRecord)
  private
    fFirstName: RawUTF8;
    fLastName: RawUTF8;
    fYearOfBirth: integer;
    fYearOfDeath: word;
    fTest : TTest;
  published
    property FirstName: RawUTF8 read fFirstName write fFirstName;
    property LastName: RawUTF8 read fLastName write fLastName;
    property YearOfBirth: integer read fYearOfBirth write fYearOfBirth;
    property YearOfDeath: word read fYearOfDeath write fYearOfDeath;
    property Test : TTest read fTest write fTEst;
  end;         

regards.

Offline

#2 2018-05-16 14:13:43

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

Re: Record cannot be published under lazarus/FPC

Indeed, records can't be used as published property since there is no RTTI for them in FPC... at least the last time we checked...
This is a FPC limitation (similar to Delphi < XE5).

You may try to define the PUBLISHRECORD conditional, and see if it works....

As a workaround, the idea is to use a TDocVariant or a RawJSON published property, then some function as getter/setter records for high-level code...

Offline

#3 2018-05-16 14:35:30

ehkhalid
Member
Registered: 2018-05-16
Posts: 12

Re: Record cannot be published under lazarus/FPC

Thank you for your quick answer ! TDocVariant is a good alternative.

Regards.

Offline

#4 2018-05-18 08:14:17

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: Record cannot be published under lazarus/FPC

We have plan to support this in NewPascal smile


best regards,
Maciej Izak

Offline

#5 2018-05-18 09:25:40

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

Re: Record cannot be published under lazarus/FPC

smile

Offline

Board footer

Powered by FluxBB