#1 2026-04-29 06:40:56

tfopc
Member
Registered: 2024-01-08
Posts: 50

Problem TSynQueue with Array of Records, SetParserType

Hi ab,
after a update to the git master i get an exception on creation of a TSynQueue object.
That app code wasn't changed and used over a long time time with a definition and initialization like this:

type TNotifyTask = record
      Name: string;
      Payload: RawJson;
      Active: boolean;
    end;

type TNotifyTaskDynArray = array of TNotifyTask;

TSynQueue.Create(TypeInfo(TNotifyTaskDynArray));

Error: "TDynArray.SetParserType(ptRecord,TNotifyTaskDynArray) unsupported ptRecord"

I don't see any posibity know to initialize the DynArray with "ptNone", because in TSynQueue.Create "aKind" is always set to "ptRecord" and in the next step a exception is raised in SetParserType.

if aKind = ptNone then
   aKind := fValues.Info.ArrayFirstFieldSort;      // compare by first field
if aKind <> ptNone then
    fValues.SetParserType(aKind, aCaseInsensitive); // set fValues.fCompare()

Don't find the reason for the breaking change. But i think there should be an option to init the queue without exception, maybe via an additional / rename of the parser TRttiParserType:

ptNone -> ptUndefined and only do a autodetect of the kind if it is the new default "ptUndefined" instead of "ptNone".

Did i miss something, or used the queue wrong?

Thank, you.

Offline

#2 2026-04-29 06:56:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,475
Website

Re: Problem TSynQueue with Array of Records, SetParserType

I don't understand what you meant.
TSynQueue.Create is set to ptNone, not ptRecord.

You just need to set aKind = ptString to the Create() constructor.

Offline

#3 2026-04-29 07:09:44

tfopc
Member
Registered: 2024-01-08
Posts: 50

Re: Problem TSynQueue with Array of Records, SetParserType

Yes, but i think set it to "ptString" or something else that didn't result in "nil" def for PT_SORT, will also has some "effects" on the TDynArray usage.
The record-data has no real unique key, so init the TDynArray with ptNone should be right in my opinion.

Beside this, why it has worked without exception before. My last git fetch before the problem was from 03.02.2026.

Offline

#4 2026-04-29 07:17:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,475
Website

Re: Problem TSynQueue with Array of Records, SetParserType

The aKind parameter has no effect in regular Push/Pop process, indeed.
But it is used e.g. for PopEquals.

I tried to reproduce your error, but I didn't get it on FPC or Delphi.

Offline

#5 2026-04-29 07:20:47

tfopc
Member
Registered: 2024-01-08
Posts: 50

Re: Problem TSynQueue with Array of Records, SetParserType

I use Delphi 7, and fValues.Info.ArrayFirstFieldSort; in TSynQueue.Create gives me a "ptRecord"

Offline

#6 2026-04-29 08:25:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,475
Website

Re: Problem TSynQueue with Array of Records, SetParserType

Offline

#7 2026-04-29 09:11:30

tfopc
Member
Registered: 2024-01-08
Posts: 50

Re: Problem TSynQueue with Array of Records, SetParserType

Ok, that is crazy. I integrated a quick test at the initialization of the program.
- here i don't get a exception and the automatic Kind detection gives "ptString"

But in the create of in my real application code it result in "ptRecord"

One thing: The Record-Definition was reduced. The real definition is like this:

type TNotifyTask = record
      Name: string;
      Filter:TNotifyTaskFilter;
      Action: TNotifyTaskEvent;
      Payload: RawJson;     
      Active: boolean; 
    end;

and Filter itself is also a record.

Maybe a option in the constructor to disable the "ArrayFirstFieldSort" detetection would be good, if you know that the queue shouldn't use a Parser.

Offline

#8 2026-04-29 09:42:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,475
Website

Re: Problem TSynQueue with Array of Records, SetParserType

Offline

#9 2026-04-29 11:12:53

tfopc
Member
Registered: 2024-01-08
Posts: 50

Re: Problem TSynQueue with Array of Records, SetParserType

Now it is also working in the app-code part.

It's strange that I'm getting two different RTTI info-kinds for the same type and the same usage.

Thank you!

Offline

Board footer

Powered by FluxBB