#1 2015-06-23 13:31:19

DigDiver
Member
Registered: 2013-04-29
Posts: 137

Bug in function Iso8601ToTimeLogPUTF8Char

The JSONToClientDataSet function sets FieldType to sftDateTime for the field Order_ID (must be sftUTF8Text)
JSON

[{"id":69736,"Order_ID":"1435051262-45869-63626","First_Name":"Alex","Last_Name":"Markov","Email":"xxx@xxx.com","program_id":13,"Subscribe_Date":"2015-06-23T09:21:02","subscribed":0}]

The problem is in procedure TSQLTable.InitFieldTypes  - the function Iso8601ToTimeLogPUTF8Char returns <> 0 value from input "1435051262-45869-63626"

        for i := 1 to fRowCount do
          if U^=nil then  // search for a non void column
            inc(U,FieldCount) else begin
            if Iso8601ToTimeLogPUTF8Char(U^,0)<>0 then  // U = "1435051262-45869-63626"
              FieldType := sftDateTime; // this was a ISO-8601 date/time value
            break;
          end;

Offline

#2 2015-06-23 14:40:55

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

Re: Bug in function Iso8601ToTimeLogPUTF8Char

The safest is to create you own TSQLTableJSON instance, then set the field types as you expect.

But I've fixed the recognition problem.
See http://synopse.info/fossil/info/afa9f26e47

The problem was that ISO-8601 is somewhat versatile, and allows both 'YYYYMMDDThhmmss' and 'YYYY-MM-DD hh:mm:ss' formats, with variations...

Offline

#3 2015-06-24 08:30:36

DigDiver
Member
Registered: 2013-04-29
Posts: 137

Re: Bug in function Iso8601ToTimeLogPUTF8Char

Thanks for the fix. It's working now.

ab wrote:

The safest is to create you own TSQLTableJSON instance, then set the field types as you expect..

The problem is that JSON returned from the server by calling:

 Res := FProp.ExecuteInlined(SQL, True);
 FResult := Res.FetchAllAsJSON;
 Ctxt.Returns(FResult);

Offline

#4 2015-06-24 10:16:47

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

Re: Bug in function Iso8601ToTimeLogPUTF8Char

Does make sense.

Did you test FetchAllAsJSON() with Expanded=false?
It would reduce the JSON size a lot.
And still be compatible with JSONToClientDataSet() AFAIK.

Offline

Board footer

Powered by FluxBB