소스 검색

* Added ftFixedChar as possible datatype for TStringFields
* The buffer from a TStringField does not nead a #0 suffix when the datatype is ftFixedChar

git-svn-id: trunk@13406 -

joost 16 년 전
부모
커밋
a0f0e8d5d5
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      packages/fcl-db/src/base/db.pas
  2. 10 1
      packages/fcl-db/src/base/fields.inc

+ 1 - 0
packages/fcl-db/src/base/db.pas

@@ -467,6 +467,7 @@ type
     procedure SetVarValue(const AValue: Variant); override;
   public
     constructor Create(AOwner: TComponent); override;
+    procedure SetFieldType(AValue: TFieldType); override;
     property FixedChar : Boolean read FFixedChar write FFixedChar;
     property Transliterate: Boolean read FTransliterate write FTransliterate;
     property Value: String read GetAsString write SetAsString;

+ 10 - 1
packages/fcl-db/src/base/fields.inc

@@ -1006,6 +1006,12 @@ begin
   FSize:=20;
 end;
 
+procedure TStringField.SetFieldType(AValue: TFieldType);
+begin
+  if avalue in [ftString, ftFixedChar] then
+    SetDataType(AValue);
+end;
+
 class procedure TStringField.CheckTypeSize(AValue: Longint);
 
 begin
@@ -1065,7 +1071,10 @@ end;
 function TStringField.GetDataSize: Integer;
 
 begin
-  Result:=Size+1;
+  if DataType=ftFixedChar then
+    Result:=Size
+  else
+    Result:=Size+1;
 end;
 
 function TStringField.GetDefaultWidth: Longint;