[5.4] Add an unsignedDecimal method to Laravel Schema Blueprint#20243
Conversation
… a unit test for it. Improves solution offered to Issue 875
…pace automatically.
|
Did you test that on MySQL, PostgreSQL and SqlServer? |
|
It will not work on PostgreSQL and SQL Server because they follow the sql standard, and there's no such thing as unsigned numerics. If you want to force non-negative values you use constraints, not data types.
Source: https://en.wikibooks.org/wiki/Structured_Query_Language/Data_Types#Exact_Numeric
Source: https://en.wikibooks.org/wiki/Structured_Query_Language/Data_Types#Approximate_Numeric All the data types in PostgreSQL: Documentation: 9.5: Data Types are signed, On the other hand, this PR makes sense to bring consistency to the schema builder api even if the underlying database doesn't support the result. |
I did not test on PostgreSQL nor SqlServer, however I did test with the new PHPunit test provided with this PR and verified it passes the test and verified the code works against MySQL.
That was my thought as well. The "unsigned[NumericType]" methods are convenience wrappers. I've merely added one that seemed oddly missing. |
|
@sisve thanks. |
|
In MySQL 8.0.17 https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-17.html "The UNSIGNED attribute is deprecated for columns of type FLOAT, DOUBLE, and DECIMAL (and any synonyms) and support for it will be removed in a future MySQL version. Consider using a simple CHECK constraint instead for such columns." |
… along with a unit test for it. Improves solution offered to Issue 875.