From a31b420eb194f9a2110eb95d93089c650e26440e Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 29 Dec 2004 20:27:08 +0000 Subject: [PATCH] + Patch from Joost van der Sluis to correct AsVariant --- fcl/db/fields.inc | 117 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/fcl/db/fields.inc b/fcl/db/fields.inc index 9281ba672f..23a57144a2 100644 --- a/fcl/db/fields.inc +++ b/fcl/db/fields.inc @@ -231,6 +231,7 @@ Const SDateTime = 'TDateTime'; SFloat = 'Float'; SInteger = 'Integer'; + SVariant = 'Variant'; SString = 'String'; constructor TField.Create(AOwner: TComponent); @@ -327,6 +328,13 @@ begin AccessError(SInteger); end; +function TField.GetAsVariant: Variant; + +begin + AccessError(SVariant); +end; + + function TField.GetAsInteger: Integer; begin @@ -339,6 +347,20 @@ begin AccessError(SString); end; +function TField.GetOldValue: Variant; + +var SaveState : tDatasetState; + +begin + with FDataset do + begin + SaveState := State; + SetTempState(dsOldValue); + Result := GetAsVariant; + RestoreState(SaveState); + end; +end; + function TField.GetCanModify: Boolean; begin @@ -482,6 +504,13 @@ begin AccessError(SFloat); end; +procedure TField.SetAsVariant(AValue: Variant); + +begin + AccessError(SVariant); +end; + + procedure TField.SetAsLongint(AValue: Longint); begin @@ -699,6 +728,18 @@ begin Result:=''; end; +function TStringField.GetAsVariant: Variant; + +Var s : string; + +begin + If GetValue(s) then + Result:=s + else + Result:=Null; +end; + + function TStringField.GetDataSize: Word; begin @@ -831,6 +872,17 @@ begin Result:=0; end; +function TLongintField.GetAsVariant: Variant; + +Var L : Longint; + +begin + If GetValue(L) then + Result:=L + else + Result:=Null; +end; + function TLongintField.GetAsString: string; Var L : Longint; @@ -902,6 +954,12 @@ begin RangeError(Avalue,FMinrange,FMaxRange); end; +procedure TLongintField.SetAsVariant(AValue: Variant); + +begin + SetAsLongint(AValue); +end; + procedure TLongintField.SetAsString(const AValue: string); Var L,Code : longint; @@ -984,6 +1042,17 @@ begin Result:=0; end; +function TLargeIntField.GetAsVariant: Variant; + +Var L : Largeint; + +begin + If GetValue(L) then + Result:=L + else + Result:=Null; +end; + function TLargeintField.GetAsLongint: Longint; begin @@ -1173,6 +1242,17 @@ begin Result:=0.0; end; +function TFloatField.GetAsVariant: Variant; + +Var f : Double; + +begin + If GetData(@f) then + Result := f + else + Result:=Null; +end; + function TFloatField.GetAsLongint: Longint; begin @@ -1270,6 +1350,17 @@ begin Result:=False; end; +function TBooleanField.GetAsVariant: Variant; + +Var b : boolean; + +begin + If GetData(@b) then + Result := b + else + Result:=Null; +end; + function TBooleanField.GetAsString: string; Var B : boolean; @@ -1353,6 +1444,16 @@ begin Result:=0; end; +function TDateTimeField.GetAsVariant: Variant; + +Var d : tDateTime; + +begin + If Getdata(@d) then + Result := d + else + Result:=Null; +end; function TDateTimeField.GetAsFloat: Double; @@ -1583,6 +1684,17 @@ begin result := C; end; +function TBCDField.GetAsVariant: Variant; + +Var c : system.Currency; + +begin + If GetData(@c) then + Result := c + else + Result:=Null; +end; + function TBCDField.GetAsFloat: Double; begin @@ -2095,7 +2207,10 @@ end; { $Log$ - Revision 1.19 2004-12-13 19:20:42 michael + Revision 1.20 2004-12-29 20:27:08 michael + + Patch from Joost van der Sluis to correct AsVariant + + Revision 1.19 2004/12/13 19:20:42 michael * Patch from Joost van der Sluis - fixed bug #3180, TFields.Clear implemented - implemented TLargeintField