[DBIx-Class-Devel] [dbsrgits/sql-translator] Remove size on floating point data types during MySQL field normalization (#110)

Johannes Piehler notifications at github.com
Mon Aug 6 16:47:42 GMT 2018


**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
You can view, comment on, or merge this pull request online at:

  https://github.com/dbsrgits/sql-translator/pull/110

-- Commit Summary --

  * Remove normalisation size on floating point types

-- File Changes --

    M lib/SQL/Translator/Parser/MySQL.pm (7)
    M t/30sqlt-new-diff-mysql.t (14)
    M t/30sqlt-new-diff-sqlite.t (4)
    M t/data/diff/create1.yml (3)
    M t/data/diff/create2.yml (3)

-- Patch Links --

https://github.com/dbsrgits/sql-translator/pull/110.patch
https://github.com/dbsrgits/sql-translator/pull/110.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/110
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20180806/c7dcc86a/attachment.htm>


More information about the DBIx-Class-Devel mailing list