symfony: Serializer Component - decimal with scale not working
Symfony version(s) affected: 4.2.3 (and 4)
Description
The scale of the attribut is not working when the view return the data.
How to reproduce
Set a decimal attribut in the entity
example
/**
* @ORM\Column(type="decimal", precision=6, scale=2)
* @Groups({"contract", "contracts", "contract_lite"})
*/
private $quantity;
in the controller, return the view of the group, example :
@Rest\View(serializerGroups={"contract_lite"}
So I POST the value “3.86” in quantity, if I dump the object I have “3.86” but it return me “3.859999999999999875655021241982467472553253173828125”
Possible Solution
Add the possibility to change the type or specify the scale?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (5 by maintainers)
Hi @Snowbaha, the ‘scale’ value you’re entering refers to using Doctrine to configure the scale setting in the column in SQL - is it possible that you’re running into the known issue with Float Precision in PHP? http://php.net/manual/en/language.types.float.php