mORMot使用synDBDataSet时字段类型不正确引起的问题

当SQL表中的nvarchar字段类型内容为null时synDBDataSet使用ftwideMemo类型引起不能修改的问题,按下面红字修改synDBVCL.pas就可以:

synDBVCL.pas

procedure TSynBinaryDataSet.InternalInitFieldDefs;
var F: integer;
    DBType: TFieldType;
begin
  FieldDefs.Clear;
  if fDataAccess=nil then
    exit;
  for F := 0 to fDataAccess.ColumnCount-1 do
    with fDataAccess.Columns[F] do begin
    case ColumnType of
    SynCommons.ftInt64: DBType := ftLargeint;
    SynCommons.ftDate:  DBType := ftDateTime;
    SynCommons.ftUTF8:
      if ColumnDataSize=0 then
        DBType := ftWideString  else    //ftDefaultMemo else
       DBType := ftWideString; // means UnicodeString for Delphi 2009+
    SynCommons.ftBlob:  DBType := ftBlob;
    SynCommons.ftDouble, SynCommons.ftCurrency: DBType := ftFloat;
    else raise EDatabaseError.CreateFmt(
      'GetFieldData ColumnType=%s',[TSQLDBFieldTypeToString(ColumnType)]);
    end;
    FieldDefs.Add(UTF8ToString(ColumnName),DBType,ColumnDataSize);
  end;
end;

猜你喜欢

转载自www.cnblogs.com/qiufeng2014/p/9147159.html