#1 2016-09-17 09:22:23

merlin352
Member
Registered: 2016-09-05
Posts: 5

Truncated variabel length strings in mORMotVCL

Hello

If a RawUTF8 field is defined without an index modifier mORMotVCL sets the DataSize to 1 in

procedure TSynSQLTableDataSet.InternalInitFieldDefs;
.
.
.
.
    sftUTF8Text: begin
      DataSize := fTable.FieldLengthMax(F,True);  // <--- Here 1 is returned if no MaxSize defined
      {$ifndef UNICODE} // for Delphi 2009+ TWideStringField = UnicodeString! 
      if fForceWideString then
        DBType := ftWideString else
      {$endif}
        DBType := ftDefaultVCLString;
    end;

I propose the following change :

procedure TSynSQLTableDataSet.InternalInitFieldDefs;
.
.
.
.
    sftUTF8Text: begin
      DataSize := fTable.FieldLengthMax(F,false);
      if DataSize = 0 then                             // variable length
        DataSize := dsMaxStringSize;                   // this is the maximum size DB unit can handle.
      {$ifndef UNICODE} // for Delphi 2009+ TWideStringField = UnicodeString! 
      if fForceWideString then
        DBType := ftWideString else
      {$endif}
        DBType := ftDefaultVCLString;
    end;

Greetings

Offline

Board footer

Powered by FluxBB