Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1,283
    • Issues 1,283
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 55
    • Merge requests 55
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPCFPC
  • FPC SourceFPC Source
  • Issues
  • #39261
Closed
Open
Created Jul 19, 2021 by FPC Admin account@fpc_adminOwner

Unable to set value to FmtBCDField because of wrong Min/Max value check

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking