mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 11:13:02 +02:00
fcl-db/dbase:
* attempt fix for mantis #10174: don't pass DBase size for ftBCD fields when creating FPC fields. to do: verify if we need to do this for other field types (ftWideString?) * cosmetic clarifications git-svn-id: trunk@24156 -
This commit is contained in:
parent
414e9555b6
commit
bb83e51f65
@ -1064,8 +1064,9 @@ begin
|
|||||||
Inc(N);
|
Inc(N);
|
||||||
TempFieldDef.FieldName:=BaseName+IntToStr(N);
|
TempFieldDef.FieldName:=BaseName+IntToStr(N);
|
||||||
end;
|
end;
|
||||||
// add field
|
// add field, passing dbase native size if relevant
|
||||||
if TempFieldDef.FieldType in [ftString, ftBCD, ftBytes] then
|
// todo: add ftWideString, perhaps more fields?
|
||||||
|
if TempFieldDef.FieldType in [ftString, ftBytes] then
|
||||||
FieldDefs.Add(TempFieldDef.FieldName, TempFieldDef.FieldType, TempFieldDef.Size, false)
|
FieldDefs.Add(TempFieldDef.FieldName, TempFieldDef.FieldType, TempFieldDef.Size, false)
|
||||||
else
|
else
|
||||||
FieldDefs.Add(TempFieldDef.FieldName, TempFieldDef.FieldType, 0, false);
|
FieldDefs.Add(TempFieldDef.FieldName, TempFieldDef.FieldType, 0, false);
|
||||||
|
@ -40,7 +40,9 @@ type
|
|||||||
procedure SetFieldType(lFieldType: TFieldType);
|
procedure SetFieldType(lFieldType: TFieldType);
|
||||||
procedure SetSize(lSize: Integer);
|
procedure SetSize(lSize: Integer);
|
||||||
procedure SetPrecision(lPrecision: Integer);
|
procedure SetPrecision(lPrecision: Integer);
|
||||||
|
// Converts VCL/LCL field types to dbf native field type markers ('C' etc)
|
||||||
procedure VCLToNative;
|
procedure VCLToNative;
|
||||||
|
// Converts dbf native field type markers ('C' etc) to VCL/LCL field types
|
||||||
procedure NativeToVCL;
|
procedure NativeToVCL;
|
||||||
procedure FreeBuffers;
|
procedure FreeBuffers;
|
||||||
protected
|
protected
|
||||||
@ -73,10 +75,14 @@ type
|
|||||||
property CopyFrom: Integer read FCopyFrom write FCopyFrom;
|
property CopyFrom: Integer read FCopyFrom write FCopyFrom;
|
||||||
published
|
published
|
||||||
property FieldName: string read FFieldName write FFieldName;
|
property FieldName: string read FFieldName write FFieldName;
|
||||||
|
// VCL/LCL field type mapped to this field
|
||||||
property FieldType: TFieldType read FFieldType write SetFieldType;
|
property FieldType: TFieldType read FFieldType write SetFieldType;
|
||||||
|
// Native dbf field type
|
||||||
property NativeFieldType: TDbfFieldType read FNativeFieldType write SetNativeFieldType;
|
property NativeFieldType: TDbfFieldType read FNativeFieldType write SetNativeFieldType;
|
||||||
property NullPosition: integer read FNullPosition write FNullPosition;
|
property NullPosition: integer read FNullPosition write FNullPosition;
|
||||||
|
// Size in dbase file (not VCL/LCL)
|
||||||
property Size: Integer read FSize write SetSize;
|
property Size: Integer read FSize write SetSize;
|
||||||
|
// Precision in dbase file (not VCL/LCL)
|
||||||
property Precision: Integer read FPrecision write SetPrecision;
|
property Precision: Integer read FPrecision write SetPrecision;
|
||||||
property Required: Boolean read FRequired write FRequired;
|
property Required: Boolean read FRequired write FRequired;
|
||||||
end;
|
end;
|
||||||
@ -110,12 +116,9 @@ uses
|
|||||||
|
|
||||||
{$I dbf_struct.inc}
|
{$I dbf_struct.inc}
|
||||||
|
|
||||||
// I keep changing that fields...
|
|
||||||
// Last time has been asked by Venelin Georgiev
|
|
||||||
// Is he going to be the last ?
|
|
||||||
const
|
const
|
||||||
(*
|
(*
|
||||||
The theory until now was :
|
The theory is:
|
||||||
ftSmallint 16 bits = -32768 to 32767
|
ftSmallint 16 bits = -32768 to 32767
|
||||||
123456 = 6 digit max theorically
|
123456 = 6 digit max theorically
|
||||||
DIGITS_SMALLINT = 6;
|
DIGITS_SMALLINT = 6;
|
||||||
@ -127,9 +130,9 @@ The theory until now was :
|
|||||||
DIGITS_LARGEINT = 20;
|
DIGITS_LARGEINT = 20;
|
||||||
|
|
||||||
But in fact if I accept 6 digits into a ftSmallInt then tDbf will not
|
But in fact if I accept 6 digits into a ftSmallInt then tDbf will not
|
||||||
being able to handles fields with 999999 (6 digits).
|
be able to handles fields with 999999 (6 digits).
|
||||||
|
|
||||||
So I now oversize the field type in order to accept anithing coming from the
|
So I oversize the field type in order to accept anything coming from the
|
||||||
database.
|
database.
|
||||||
ftSmallint 16 bits = -32768 to 32767
|
ftSmallint 16 bits = -32768 to 32767
|
||||||
-999 to 9999
|
-999 to 9999
|
||||||
@ -380,10 +383,10 @@ begin
|
|||||||
{
|
{
|
||||||
To do: add support for Visual Foxpro types
|
To do: add support for Visual Foxpro types
|
||||||
http://msdn.microsoft.com/en-US/library/ww305zh2%28v=vs.80%29.aspx
|
http://msdn.microsoft.com/en-US/library/ww305zh2%28v=vs.80%29.aspx
|
||||||
P Picture (in at least Visual FoxPro)
|
P Picture (perhaps also in FoxPro)
|
||||||
V Varchar/varchar binary (in at least Visual FoxPro) 1 byte up to 255 bytes (or perhaps 254)
|
V Varchar/varchar binary (perhaps also in FoxPro) 1 byte up to 255 bytes (or perhaps 254)
|
||||||
W Blob (in at least Visual FoxPro), 4 bytes in a table; stored in .fpt
|
W Blob (perhaps also in FoxPro), 4 bytes in a table; stored in .fpt
|
||||||
Q Varbinary (in at least Visual Foxpro)
|
Q Varbinary (perhaps also in Foxpro)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FNativeFieldType := #0;
|
FNativeFieldType := #0;
|
||||||
|
Loading…
Reference in New Issue
Block a user