mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
computing entity changeset fails if property is typed decimal -> float #7441
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 @forgie1 on GitHub (Nov 22, 2024).
Bug Report
Version | 2.19.8
Summary
While EM::flush() this entity will be always considered changed, see generated changeset:
Current behavior
Unchanged decimal property of entity with float type is always considered changed.
If there is not float type, everything works just fine:
Expected behavior
If property was not changed, do not consider it changed.
How to reproduce
Calling
EM::persist($entity)and thanEM::flush($enitty)see a description above.@derrabus commented on GitHub (Nov 22, 2024):
Decimals are mapped to strings. The "change" happens because you use a native type
float. Change it tostringand you're good.@fnagel commented on GitHub (Dec 10, 2024):
Similar issue here (started with 2.17.x).
Dump question: its a float value so why use a string for it? Feels wrong to me to use a string when its actually a float.
@michaljusiega commented on GitHub (Dec 10, 2024):
Using
FLOATtype instead ofDECIMALkeeps value as float. Try it ;)@fnagel commented on GitHub (Dec 10, 2024):
Thanks for the hint!
This will change my DB field from
NUMERIC(9, 6)toDOUBLE PRECISION. I'm using this for lat/lng values which are normally defined as decimal. Seems usingFLOAT(which results inDOUBLE PRECISION) is a little too much precision for what I need. Maybesmallfloatwould work (but its not available in v3.9)?https://stackoverflow.com/questions/159255/what-is-the-ideal-data-type-to-use-when-storing-latitude-longitude-in-a-mysql/25120203#25120203
https://stackoverflow.com/questions/1196415/what-datatype-to-use-when-storing-latitude-and-longitude-data-in-sql-databases
@derrabus commented on GitHub (Dec 10, 2024):
A decimal is not a float. https://3v4l.org/M5MuY
@fnagel commented on GitHub (Dec 11, 2024):
@derrabus That makes sense, thanks for pointing out! I found this beautiful website could help understand better whats the issue here: https://floating-point-gui.de/