Remove size on floating point data types during MySQL field normalization #110
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.
Summary:
This merge request removes the forced 2 precision and 8 digits size limit for floating point number data types in the MySQL field normalization and instead force removes size for these data types.
Some unit tests are updated to reflect this change.
Reason for this change:
While sane size limits are useful for fixed point data types like decimal such limits make little sense for floating point data types. Setting the size for floating point data types does not result in less storage being used but will just try to badly truncate the input and mask the output (or raise an error in strict mode on bad input).
For use cases where size restricted data is required or desired it is highly recommended to use fixed point data types as they don't have impression errors in their given number space as opposed to IEEE 754 floating point numbers (As an example: 0.1 and 0.2 are not directly representable as IEEE 754 number no matter how good the precision is). IEEE 754 floating point numbers are simply not designed for such use cases but to closer approximate natural numbers.
Being able to set size limits to floating point numbers can also encourage the use of bad practices like the classic case of money represented as floating point numbers.
Lastly, the MySQL documentation recommends not using precision and number of digits for maximum portability.
https://dev.mysql.com/doc/refman/en/floating-point-types.html