Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove size on floating point data types during MySQL field normalization #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpiautinity
Copy link

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

@codecov
Copy link

codecov bot commented Aug 6, 2018

Codecov Report

Merging #110 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #110      +/-   ##
==========================================
+ Coverage    21.5%   21.51%   +0.01%     
==========================================
  Files          71       71              
  Lines       19914    19917       +3     
  Branches     5728     5729       +1     
==========================================
+ Hits         4283     4286       +3     
- Misses      14922    14924       +2     
+ Partials      709      707       -2
Impacted Files Coverage Δ
lib/SQL/Translator/Parser/MySQL.pm 71.72% <100%> (-0.82%) ⬇️
lib/SQL/Translator/Producer/MySQL.pm 91.08% <0%> (+0.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86c68a0...d19e2c6. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant