Unable to set value to FmtBCDField because of wrong Min/Max value check
Original Reporter info from Mantis: zgabrovski
-
Reporter name: Zdravko Gabrovski
Original Reporter info from Mantis: zgabrovski
- Reporter name: Zdravko Gabrovski
Description:
A simple TBufdataset component with one field "f1" with type "TFmtBCDField". Size=6, Precision=18.
Although MinValue=0 and MaxValue=0, when I try to add a new value '1' to the field with code
BufDataset1.FieldByName('F1').AsFloat:=1;
I received:
Field "f1" error: 1.00 is not between 0.00 and 0.00.
Press OK to ignore and risk data corruption.
Press Abort to kill the program.
The problem comes from method TFMTBCDField.CheckRange in fields.inc:
Function TFMTBCDField.CheckRange(AValue: TBCD) : Boolean;
begin
If (FMinValue<>0) or (FMaxValue<>0) then <--------- This check failed
Result:=(AValue>=FMinValue) and (AValue<=FMaxValue)
else
Result:=True;
end;
SomeHow TBCD FMinValue and FMaxValue are <> than '0'
if I modify like this:
Function TFMTBCDField.CheckRange(AValue: TBCD) : Boolean;
var Z : TBcd
begin
Z := 0;
If (FMinValue<>Z)) or (FMaxValue<>Z) then
Result:=(AValue>=FMinValue) and (AValue<=FMaxValue)
else
Result:=True;
end;
It works fine.
Steps to reproduce:
just open attached sample lazarus project and click MakeTest button.
Mantis conversion info:
- Mantis ID: 39261
- OS: All
- OS Build: all
- Build: trunk
- Platform: all
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 49623 (#57391770)
- Target version: 4.0.0