mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-06 13:38:30 +02:00
fcl-db: base: when reporting RangeError take into account also user defined MinValue, MaxValue. Bug #26606
git-svn-id: trunk@28514 -
This commit is contained in:
parent
8169fd6255
commit
bfb08c957e
@ -1331,7 +1331,7 @@ end;
|
|||||||
procedure TNumericField.RangeError(AValue, Min, Max: Double);
|
procedure TNumericField.RangeError(AValue, Min, Max: Double);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DatabaseErrorFMT(SRangeError,[AValue,Min,Max,FieldName]);
|
DatabaseErrorFmt(SRangeError,[AValue,Min,Max,FieldName]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TNumericField.SetDisplayFormat(const AValue: string);
|
procedure TNumericField.SetDisplayFormat(const AValue: string);
|
||||||
@ -1474,12 +1474,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLongintField.SetAsInteger(AValue: Longint);
|
procedure TLongintField.SetAsInteger(AValue: Longint);
|
||||||
|
var Min, Max: Longint;
|
||||||
begin
|
begin
|
||||||
If CheckRange(AValue) then
|
If CheckRange(AValue) then
|
||||||
SetData(@AValue)
|
SetData(@AValue)
|
||||||
else
|
else
|
||||||
RangeError(AValue,FMinRange,FMaxRange);
|
begin
|
||||||
|
if FMinValue<>0 then Min:=FMinValue else Min:=FMinRange;
|
||||||
|
if FMaxValue<>0 then Max:=FMaxValue else Max:=FMaxRange;
|
||||||
|
RangeError(AValue,Min,Max);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLongintField.SetVarValue(const AValue: Variant);
|
procedure TLongintField.SetVarValue(const AValue: Variant);
|
||||||
@ -1500,27 +1504,22 @@ begin
|
|||||||
If Code=0 then
|
If Code=0 then
|
||||||
SetAsInteger(L)
|
SetAsInteger(L)
|
||||||
else
|
else
|
||||||
DatabaseErrorFMT(SNotAnInteger,[AValue]);
|
DatabaseErrorFmt(SNotAnInteger,[AValue]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TLongintField.CheckRange(AValue : longint) : Boolean;
|
Function TLongintField.CheckRange(AValue : longint) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
result := true;
|
if FMaxValue = 0 then
|
||||||
if (FMaxValue=0) then
|
Result := AValue<=FMaxRange
|
||||||
begin
|
|
||||||
if (AValue>FMaxRange) Then result := false;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if AValue>FMaxValue then result := false;
|
Result := AValue<=FMaxValue;
|
||||||
|
|
||||||
if (FMinValue=0) then
|
if FMinValue = 0 then
|
||||||
begin
|
Result := Result and (AValue>=FMinRange)
|
||||||
if (AValue<FMinRange) Then result := false;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if AValue<FMinValue then result := false;
|
Result := Result and (AValue>=FMinValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TLongintField.SetMaxValue (AValue : longint);
|
Procedure TLongintField.SetMaxValue (AValue : longint);
|
||||||
@ -1668,7 +1667,7 @@ begin
|
|||||||
If Code=0 then
|
If Code=0 then
|
||||||
SetAsLargeint(L)
|
SetAsLargeint(L)
|
||||||
else
|
else
|
||||||
DatabaseErrorFMT(SNotAnInteger,[AValue]);
|
DatabaseErrorFmt(SNotAnInteger,[AValue]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1680,20 +1679,15 @@ end;
|
|||||||
Function TLargeintField.CheckRange(AValue : largeint) : Boolean;
|
Function TLargeintField.CheckRange(AValue : largeint) : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
result := true;
|
if FMaxValue = 0 then
|
||||||
if (FMaxValue=0) then
|
Result := AValue<=FMaxRange
|
||||||
begin
|
|
||||||
if (AValue>FMaxRange) Then result := false;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if AValue>FMaxValue then result := false;
|
Result := AValue<=FMaxValue;
|
||||||
|
|
||||||
if (FMinValue=0) then
|
if FMinValue = 0 then
|
||||||
begin
|
Result := Result and (AValue>=FMinRange)
|
||||||
if (AValue<FMinRange) Then result := false;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if AValue<FMinValue then result := false;
|
Result := Result and (AValue>=FMinValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TLargeintField.SetMaxValue (AValue : largeint);
|
Procedure TLargeintField.SetMaxValue (AValue : largeint);
|
||||||
@ -2393,7 +2387,7 @@ class procedure TBCDField.CheckTypeSize(AValue: Longint);
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
If not (AValue in [0..4]) then
|
If not (AValue in [0..4]) then
|
||||||
DatabaseErrorfmt(SInvalidFieldSize,[AValue]);
|
DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBCDField.GetAsBCD: TBCD;
|
function TBCDField.GetAsBCD: TBCD;
|
||||||
@ -2564,7 +2558,7 @@ end;
|
|||||||
class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
|
class procedure TFMTBCDField.CheckTypeSize(AValue: Longint);
|
||||||
begin
|
begin
|
||||||
If AValue > MAXFMTBcdFractionSize then
|
If AValue > MAXFMTBcdFractionSize then
|
||||||
DatabaseErrorfmt(SInvalidFieldSize,[AValue]);
|
DatabaseErrorFmt(SInvalidFieldSize,[AValue]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TFMTBCDField.Create(AOwner: TComponent);
|
constructor TFMTBCDField.Create(AOwner: TComponent);
|
||||||
|
Loading…
Reference in New Issue
Block a user