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

[5.4] Add an unsignedDecimal method to Laravel Schema Blueprint #20243

Merged
merged 2 commits into from
Jul 27, 2017

Conversation

phpguru
Copy link
Contributor

@phpguru phpguru commented Jul 24, 2017

… along with a unit test for it. Improves solution offered to Issue 875.

@tillkruss
Copy link
Contributor

Did you test that on MySQL, PostgreSQL and SqlServer?

@sisve
Copy link
Contributor

sisve commented Jul 25, 2017

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.

Exact numeric types hold numeric values without digits after the decimal or with a firm number of digits after the decimal. All exact numeric types are signed.

Source: https://en.wikibooks.org/wiki/Structured_Query_Language/Data_Types#Exact_Numeric

Approximate numeric types hold numeric values with an implementation defined precision (after the decimal). All approximate numeric types are signed. Their primary use cases are scientific computations.

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,
there are no unsigned versions.

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.

@phpguru
Copy link
Contributor Author

phpguru commented Jul 25, 2017

Did you test that on MySQL, PostgreSQL and SqlServer?

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.

this PR makes sense to bring consistency to the schema builder api even if the
underlying database doesn't support the result.

That was my thought as well. The "unsigned[NumericType]" methods are convenience wrappers. I've merely added one that seemed oddly missing.

@tillkruss tillkruss changed the title Add an unsignedDecimal method to Laravel Schema Blueprint [5.4] Add an unsignedDecimal method to Laravel Schema Blueprint Jul 26, 2017
@tillkruss
Copy link
Contributor

@sisve thanks.

@taylorotwell taylorotwell merged commit 62c63be into laravel:5.4 Jul 27, 2017
@ziming
Copy link
Contributor

ziming commented Mar 9, 2020

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."

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.

5 participants