#1 2017-04-28 08:00:10

nostroyo
Member
Registered: 2015-08-19
Posts: 16

Pb TSQLRecordMany

Hi!

When i try to send an object with TSQLRecordMany properties through HTTP i've got an 406 (error execution failed (probably due to bad input parameters)).

What i've discovered is that in mormot.pas in the function JSONToObject :

 tkClass: begin
        if wasString or (P^.PropType^.ClassSQLFieldType<>sftID) then
          exit; // should have been handled above
        V := GetInteger(PropValue,err);
        if err<>0 then
          exit; // invalid value
        P^.SetOrdProp(Value,V);
      end;

In case of TSQLRecordMany the conditional expression P^.PropType^.ClassSQLFieldType <>sftID is true and the exit is executed and the function return false and this is why i've got the error.
I changed :

 if wasString or (P^.PropType^.ClassSQLFieldType<>sftID) then 

by

 if wasString or ((P^.PropType^.ClassSQLFieldType<>sftID) and (P^.PropType^.ClassSQLFieldType<>sftMany)) then 

and it's worked fine. What do you think?

Although when mORMot generate me the wrapper for crossplateform it wraps the TSQLRecordMany properties by Integer and not by TID. Is it good?

thx.

Offline

#2 2017-04-28 08:18:23

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

Re: Pb TSQLRecordMany

sftMany are never serialized, by design.
With a TSQLRecordMany field, no data is stored in the table itself, but in a separated pivot table.

Here you are serializing the pointer value of a remote TSQLRecord pivot instance in the TSQLRecordMany property, I'm afraid.
So it won't work as expected.

For SynCrossPlatform units, there is currently no support of TSQLRecordMany properties or class types.

Offline

#3 2017-04-28 08:42:03

nostroyo
Member
Registered: 2015-08-19
Posts: 16

Re: Pb TSQLRecordMany

Yeah it perfectly make sense!

I don't know why i wanted to add a pivot table properties.

Thanks for the quick answer.

Offline

Board footer

Powered by FluxBB