View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0020134 | FPC | Database | public | 2011-09-02 14:16 | 2011-09-06 10:59 |
Reporter | Assigned To | Michael Van Canneyt | |||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Platform | x64 | OS | Windows | ||
Product Version | 2.7.1 | ||||
Target Version | 2.6.0 | Fixed in Version | 3.0.0 | ||
Summary | 0020134: [Patch] DBase export: Observe field name length limits for DBaseIV,VII,Foxpro | ||||
Description | In packages\fcl-db\src\export\fpdbfexport.pp These tablelevels/formats are defined: TTableFormat = (tfDBaseIII,tfDBaseIV,tfDBaseVII,tfFoxPro); function TFPCustomDBFExport.BindFields: Boolean; there is this part (line 136): If FormatSettings.AutoRenameFields and (FormatSettings.TableFormat=tfDbaseIII) then CheckExportFieldNames; only checks for DBaseIII and ignores field length limit for the other supported formats. Attached is a patch that addresses this. | ||||
Additional Information | As best as I could figure out: the following field size limits are present for the various DBase formats: 3: DBase III: 10 characters 4: DBase IV: 10 characters 7: DBase VII: 32 characters 8: FoxPro: 10 characters 3,4: http://www.clicketyclick.dk/databases/xbase/format/dbf.html#DBF_STRUCT 7: IIRC, from http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm (forwarded by Wikipedia), but that page is down now 8: http://www.dynamic.com/v7/what-are-limitations-foxpro-full-isam-file http://www.foxite.com/archives/foxpro-field-names-0000066805.htm Apparently Visual FoxPro 8 has 27 characters in a DBC (Database container) file, but only 10 in a DBF file. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 18944 | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
2011-09-02 14:16
|
dbfexport_fieldlengthfix.patch (1,958 bytes)
diff --git a/packages/fcl-db/src/export/fpdbfexport.pp b/packages/fcl-db/src/export/fpdbfexport.pp index 621087a..cac57cf 100644 --- a/packages/fcl-db/src/export/fpdbfexport.pp +++ b/packages/fcl-db/src/export/fpdbfexport.pp @@ -42,7 +42,7 @@ Type function GetSettings: TDBFExportFormatSettings; procedure SetSettings(const AValue: TDBFExportFormatSettings); Protected - Procedure CheckExportFieldNames; virtual; + Procedure CheckExportFieldNames(const MaxFieldNameLength: integer); virtual; Function BindFields : Boolean; override; Function CreateFormatSettings : TCustomExportFormatSettings; override; @@ -97,7 +97,7 @@ begin Inherited FormatSettings.Assign(AValue); end; -procedure TFPCustomDBFExport.CheckExportFieldNames; +procedure TFPCustomDBFExport.CheckExportFieldNames(const MaxFieldNameLength: integer); Var I,J : Integer; @@ -108,10 +108,10 @@ begin For I:=0 to ExportFields.Count-1 do begin EF:=ExportFields[i]; - If (Length(EF.ExportedName)>10) then + If (Length(EF.ExportedName)>MaxFieldNameLength) then begin - FN:=Copy(EF.ExportedName,1,10); - If ExportFIelds.IndexOfExportedName(FN)<>-1 then + FN:=Copy(EF.ExportedName,1,MaxFieldNameLength); + If ExportFields.IndexOfExportedName(FN)<>-1 then begin J:=1; Repeat @@ -133,8 +133,12 @@ Var I : Integer; begin - If FormatSettings.AutoRenameFields and (FormatSettings.TableFormat=tfDbaseIII) then - CheckExportFieldNames; + // DBase III,IV, and FoxPro have a 10 character field length limit. + If FormatSettings.AutoRenameFields and (FormatSettings.TableFormat in [tfDbaseIII,tfDbaseIV,tfFoxPro]) then + CheckExportFieldNames(10); + // DBase VII has a 32 character field length limit. + If FormatSettings.AutoRenameFields and (FormatSettings.TableFormat=tfDbaseVII) then + CheckExportFieldNames(32); Result:=Inherited; try with FDBF.FieldDefs do |
|
Applied the patch. Thank you very much. |
|
Thanks for applying the patch. While I think the patch is valid, it doesn't address the entire issue. See 20163 for dbfexport test that shows this error when exporting a field with a large name. I'll raise another issue & patch when I find the solution. |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-09-02 14:16 |
|
New Issue | |
2011-09-02 14:16 |
|
Status | new => assigned |
2011-09-02 14:16 |
|
Assigned To | => Joost van der Sluis |
2011-09-02 14:16 |
|
File Added: dbfexport_fieldlengthfix.patch | |
2011-09-02 15:03 | Michael Van Canneyt | Assigned To | Joost van der Sluis => Michael Van Canneyt |
2011-09-02 15:07 | Michael Van Canneyt | Fixed in Revision | => 18944 |
2011-09-02 15:07 | Michael Van Canneyt | Status | assigned => resolved |
2011-09-02 15:07 | Michael Van Canneyt | Fixed in Version | => 2.7.1 |
2011-09-02 15:07 | Michael Van Canneyt | Resolution | open => fixed |
2011-09-02 15:07 | Michael Van Canneyt | Note Added: 0051386 | |
2011-09-02 15:07 | Michael Van Canneyt | Target Version | => 2.6.0 |
2011-09-06 08:42 |
|
Status | resolved => closed |
2011-09-06 08:42 |
|
Note Added: 0051499 |