mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Unnecessary decimal updates #5086
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Bordovsky on GitHub (Apr 8, 2016).
Originally assigned to: @Ocramius on GitHub.
Hi. I would like to make pull request, but when I tried add my branch/code I got 403 response. I will add code here, since it is nothing huge. I hope you don't mind.
When working around decimals in php, they change type. Since doctrine see them as strings and we works with them as numbers. It leads into unnecessary change set values in persisting which doesn't do any real change.
Workaround in entities seems difficult so I added few lines of code into UnitOfWork and it works, and pass all tests. I suppose others wouldn't mind if change set contained only real changes.
Here is code, it belongs on line 665 in UnitOfWork.php:
@Ocramius commented on GitHub (Apr 8, 2016):
The field is supposed to be a string, unless you actually can afford losing precision.
Comparing types always happens with strict comparison: if you want to avoid an update, then cast the value back to a
stringor use a custom type (if you can afford playing with dangerous precision).