#1 2019-04-12 05:49:43

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

Problem in OneFieldValues: RawUTF8

The problem in

function OneFieldValues(Table: TSQLRecordClass; const FieldName: RawUTF8;
      const WhereClause: RawUTF8=''; const Separator: RawUTF8=','): RawUTF8; overload;

It returns '1'#0',3,4,5,8,1,14,15' instead of '1,3,4,5,8,1,14,15' if I request FieldName = 'ID' (2 symbol length).

    for i := 0 to T.fRowCount-1 do begin // ignore fResults[0] i.e. field name

      //Lens[i] := StrLen(T.fResults[i]);  // not correct: fResults[0] is field name
      Lens[i] := StrLen(T.fResults[i+1]); // <--- correct

      inc(Len,Lens[i]+SepLen);
    end;

Please fix.

Offline

#2 2019-04-12 08:02:30

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

Re: Problem in OneFieldValues: RawUTF8

Offline

#3 2019-04-12 10:19:49

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

Re: Problem in OneFieldValues: RawUTF8

I suspect it won't work.
I didn't notice any Inc(i) in the infinite loop:

    i := 1;
    repeat
      L := Lens[i-1];
      if L<>0 then begin
        {$ifdef FPC}Move{$else}MoveFast{$endif}(T.fResults[i]^,P^,L);
        inc(P,L);
      end;
      if i=T.fRowCount then
        break;
      {$ifdef FPC}Move{$else}MoveFast{$endif}(pointer(Separator)^,P^,SepLen);
      inc(P,SepLen);
    until false;

Offline

#4 2019-04-12 12:20:56

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

Re: Problem in OneFieldValues: RawUTF8

Offline

#5 2019-04-15 09:21:34

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

Re: Problem in OneFieldValues: RawUTF8

Ok. Thanks.

Offline

Board footer

Powered by FluxBB