Allow to convert a type to a floating point #42
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Initially Formal didn't support
float
s to prevent people to use this type to store data in an unsafe way (like money for example), due to multiple bugs that may arise.But in some cases we do need to store values as floats. For example one may want to duplicate a value to an approximation and allow to search on this approximation.
One of these cases would be a system where you let users input any float value and store it as a
string
so the value never changes and duplicate this property as adecimal
to only support search up to a certain decimal part.Solution
Allow
Formal\ORM\Definition\Type
to handle thefloat
type.Notes
No
Formal\ORM\Definition\Type\FloatType
is created to prevent introducing implicits in converting the floats from the storage level.This forces users to create their own type and know which type to use in the storage.
Bugs born out of implicits can't be universally fixed by an abstraction, it's up to each app to handle them.
Even though the diff is small this will be released as a new major version since technically it's a BC break.