-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bug Report
Q | A |
---|---|
BC Break | no |
Version | 2.9.3 |
Summary
Fields with declared type float (php 7.4+) and doctrine orm type decimal are detected as changed on PreUpdate event .
Current behavior
My entity has a field of type float, which is declared as such (php 7.4). This same field has a decimal doctrine orm type.
/**
* @var float
*
* @ORM\Column(type="decimal", scale=2, precision=5)
*/
private float $discount = 0;
Problem occurs when existing entity gets persisted, but with no new changes. In concrete application, this happens when this entity is relation of some other entity that does get updated. This leads application to think update happened and update event is triggered, with following changeset logged (var_dump($args->getEntityChangeSet()))
array(1) {
["discount"]=>
array(2) {
[0]=>
string(1) "0"
[1]=>
float(0)
}
}
How to reproduce
Please checkout following code: https://github.com/vlud/doctrine-orm-float-issue-demo and follow steps defined in ReadMe to reproduce issue.
Note, that issue occurs on entity named BookingWithFloatDecimal
, and other entities are behaving as expected.
Expected behavior
PreUpdate should not be triggered when no changes are performed on entity that has field of type float and orm type of decimal. If type is omitted, event is not triggered.