Browse Source

* Do not allow values below 2 for TFloatField.Precision. Note that precision gives the total amount of digits while TFloatField.Size is not defined (Delphi-compat)

git-svn-id: trunk@12555 -
joost 16 years ago
parent
commit
f7cc1954b9
2 changed files with 10 additions and 1 deletions
  1. 2 1
      packages/fcl-db/src/base/db.pas
  2. 8 0
      packages/fcl-db/src/base/fields.inc

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

@@ -618,6 +618,7 @@ type
     FMinValue : Double;
     FPrecision : Longint;
     procedure SetCurrency(const AValue: Boolean);
+    procedure SetPrecision(const AValue: Longint);
   protected
     function GetAsFloat: Double; override;
     function GetAsLongint: Longint; override;
@@ -638,7 +639,7 @@ type
     property Currency: Boolean read FCurrency write SetCurrency default False;
     property MaxValue: Double read FMaxValue write FMaxValue;
     property MinValue: Double read FMinValue write FMinValue;
-    property Precision: Longint read FPrecision write FPrecision default 15;
+    property Precision: Longint read FPrecision write SetPrecision default 15; // min 2 instellen, delphi compat
   end;
 
 { TCurrencyField }

+ 8 - 0
packages/fcl-db/src/base/fields.inc

@@ -1690,6 +1690,14 @@ begin
   FCurrency:=AValue;
 end;
 
+procedure TFloatField.SetPrecision(const AValue: Longint);
+begin
+  if AValue > 1 then
+    FPrecision := AValue
+  else
+    FPrecision := 2;
+end;
+
 function TFloatField.GetAsFloat: Double;
 
 begin