#1 2019-10-17 19:29:14

lagodny
Member
Registered: 2015-01-28
Posts: 50

Problem in TSQLRecordMany

After upgrade to last NightlyBuild I get an error like "ITest.GetUser failed on aUser:TSQLMyUser [returned object]."
The error appears when I try to get an object that contains a field of type TSQLRecordMany.

Test Model:

  TSQLMyUser = class;

  TSQLMyRole = class(TSQLRecord)
  end;

  TSQLMyUserRole = class(TSQLRecordMany)
  private
    fSource: TSQLMyUser;
    fDest: TSQLMyRole;
  published
    property Source: TSQLMyUser read fSource; // map Source column
    property Dest: TSQLMyRole read fDest; // map Dest column
  end;

  TSQLMyUser = class(TSQLRecord)
  private
    FRoles: TSQLMyUserRole;
  published
    property Roles: TSQLMyUserRole read FRoles;
  end;

And a simple "Interface based services":

  ITest = interface(IInvokable)
    ['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
    function GetUser(out aUser: TSQLMyUser): boolean;
  end;

Offline

#2 2019-10-26 14:59:30

lagodny
Member
Registered: 2015-01-28
Posts: 50

Re: Problem in TSQLRecordMany

https://drive.google.com/open?id=1Fe43Q … n-AMgHhte9

It is the simple project to reproduce the problem.

Offline

#3 2019-10-26 19:15:39

lagodny
Member
Registered: 2015-01-28
Posts: 50

Re: Problem in TSQLRecordMany

I have compare old and new code and found out a key difference:

function PropIsIDTypeCastedField(Prop: PPropInfo; IsObj: TJSONObject;
  Value: TObject): boolean;
begin // see [22ce911c715]
  if (Value<>nil) and (Prop^.PropType^.ClassSQLFieldType=sftID) then // <-- deleted in new code
  case IsObj of
  oSQLMany:
    if IdemPropName(Prop^.Name,'source') or IdemPropName(Prop^.Name,'dest') then
      result := true else
      result := not TSQLRecord(Value).fFill.JoinedFields;
  oSQLRecord:
    result := not TSQLRecord(Value).fFill.JoinedFields;
  else result := false;
  end else
    result := false; // assume true instance by default // <-- deleted in new code
end;

ab, could you check my investigate?

Offline

#4 2019-10-26 20:38:30

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

Re: Problem in TSQLRecordMany

You are right.

There was a regression in this commit.

Please check https://synopse.info/fossil/info/5662a94809

Offline

#5 2019-10-27 06:33:01

lagodny
Member
Registered: 2015-01-28
Posts: 50

Re: Problem in TSQLRecordMany

Thanks, ab. It is ok now

Offline

#6 2019-10-27 07:11:16

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

Re: Problem in TSQLRecordMany

Great!

Thanks a lot for the feedback.
And sorry for the bug.

Offline

Board footer

Powered by FluxBB