#1 2011-12-19 16:59:16

Sir Rufo
Member
Registered: 2011-10-14
Posts: 24

TStrings in TSQLRecord

There is a little bug when using TStrings (e.g. TStringList) in a TSQLRecord

The last entry in the StringList-Data will not restore in the Record:

// SQLite3Commons.pas
function JSONToObject(var ObjectInstance; From: PUTF8Char; var Valid: boolean): PUTF8Char;
...
    oStrings: begin
...
          '"': begin
            result := From;
            PropValue := GetJSONField(From,From,@wasString,@EndOfObject);

            // After getting the last PropValue From is NIL
            // unfortunately this causes an exit, and PropValue will not get into the StringList!

            if (PropValue=nil) or (From=nil) or not wasString then
              exit;
            Str.Add(UTF8ToString(PropValue));
            case EndOfObject of
              ']': break;
              ',': continue;
              else exit;

Offline

#2 2012-01-15 09:13:14

Sir Rufo
Member
Registered: 2011-10-14
Posts: 24

Re: TStrings in TSQLRecord

The Error is still there ... here a Patch for this

@@ -17867,7 +17867,7 @@
           '"': begin
             result := From;
             PropValue := GetJSONField(From,From,@wasString,@EndOfObject);
-            if (PropValue=nil) or (From=nil) or not wasString then
+            if (PropValue=nil) {or (From=nil)} or not wasString then
               exit;
             Str.Add(UTF8ToString(PropValue));
             case EndOfObject of

Offline

#3 2012-01-16 08:43:25

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

Re: TStrings in TSQLRecord

The TRawUTF8List process was correct about this last item, but TStrings was not!
Thanks for the report.
See http://synopse.info/fossil/info/3e56f6ef4d

I've also made it a bit faster (avoided one allocation at UTF8ToString call).

Offline

Board footer

Powered by FluxBB