-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[11.x] Make floating-point types consistent #48861
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
Conversation
|
Please provide the documentation that would need to be included in a step by step upgrade for Laravel 11 if this PR was merged. |
|
Mark as ready for review when done please. |
|
Why was the unsigned removed from decimal()? Who made the decision to merge this. I use this and am having issues upgrading to 11. 1 database out of them all deprecating a feature doesn't mean it should be removed. Mariadb still has it and mysql hasn't got rid of it yet. What a stupid decision to allow the removal of the unsigned attribute on decimal() |
|
@bluedreamer just use |
|
But why was a breaking public API change allowed for what amounts to a cosmetic reason? Why wasn't the param deprecated in documentation only? Wasted my time. |
|
Regardless of anything, the PRs that @hafezdivandari delivers are always of a high standard of description, incredible! |
|
Laravel: Heads up, your documentation specifies before your PR This is not the case.
I have found having to set the precision explicitly to |
|
@Vimiso I've explained that the default
|
|
Ah got you, my bad! |
Fixes #3151, #7298, #9089, #9103, #13258, #18776, #21032, #21827, #42308 Related to laravel/ideas#1527 and #47080
This PR makes
floatanddoublecolumn types consistent across all databases and also removesunsignedDecimal,unsignedDouble, andunsignedFloatcolumn types.Why?
Almost all databases have 4-bytes single-precision and 8-bytes double-precision storage types when declaring floating-point types (approximate numeric data values). Current syntax is inconsistent on Laravel and there is no way to declare precision value.
FLOAT(M,D)andDOUBLE(M,D)syntax is deprecated and you should expect support for it to be removed in a future version of MySQL. SourceUNSIGNEDattribute is deprecated for columns of typeFLOAT,DOUBLE, andDECIMAL(and any synonyms); you should expect support for it to be removed in a future version of MySQL. SourceChanges
$blueprint->float($column, $total = 8, $places = 2, $unsigned = false)to$blueprint->float($column, $precision = 53)$blueprint->double($column, $total = 8, $places = 2, $unsigned = false)to$blueprint->double($column)$blueprint->decimal($column, $total = 8, $places = 2, $unsigned = false)to$blueprint->decimal($column, $total = 8, $places = 2)$blueprint->unsignedFloat()$blueprint->unsignedDouble()$blueprint->unsignedDecimal()Before this PR
$table->float('foo')double(8, 2)double precisionfloatfloat$table->float('foo', 9)double(9, 2)double precisionfloatfloat$table->float('foo', 9, 3)double(9, 3)double precisionfloatfloat$table->float('foo', 9, null)doubledouble precisionfloatfloat$table->float('foo', null, null)doubledouble precisionfloatfloat$table->double('foo')double(8, 2)double precisionfloatfloat$table->double('foo', 9)double(9, 2)double precisionfloatfloat$table->double('foo', 9, 3)double(9, 3)double precisionfloatfloat$table->double('foo', 9, null)doubledouble precisionfloatfloat$table->double('foo', null, null)doubledouble precisionfloatfloatAfter this PR
$table->float('foo')float(53)float(53)float(53)float$table->float('foo', 24)float(24)float(24)float(24)float$table->float('foo', null)floatfloatfloatfloat$table->double('foo')doubledouble precisiondouble precisiondoubleComparison of Floating-Point Types on Different DBs
FLOAT(M, D)REAL)DOUBLE(M, D)REAL)FLOAT(1 to 24)FLOAT)real)float(24))REAL)FLOAT(25 to 53)DOUBLE)double precision)float(53))REAL)FLOATFLOAT)double precision)float(53))REAL)DOUBLEDOUBLE)REAL)DOUBLE PRECISIONDOUBLE)double precision)float(53))REAL)REALDOUBLE)real)float(24))REAL)Upgrade guide
The
doubleandfloatcolumn types of database migrations have been rewritten to make these types consistent across all databases:The
doublecolumn type now creates aDOUBLEequivalent column without total digits and places (digits after decimal point), which is the standard syntax in SQL. Therefore, you may remove the arguments for$totaland$places:The
floatcolumn type now creates aFLOATequivalent column without total digits and places (digits after decimal point), but with an optional$precisionspecification to determine storage size as a 4-byte single-precision column or an 8-byte double-precision column. Therefore, you may remove the arguments for$totaland$placesand specify the optional$precisionto your desired value and according to your database's documentation. The default$precisionis set to 53 that would result in 8-byte double-precision column on all database drivers:The
$unsignedparameter of the$table->decimal(),$table->double(), and$table->float()methods has been removed. Actually, this were only supported on MySQL. However, You may force deprecatedUNSIGNEDattribute using->unsigned()modifier:The
unsignedDecimal,unsignedDouble, andunsignedFloatcolumn types have been removed. Therefore, you may use equivalent column types and forcing deprecatedUNSIGNEDattribute using->unsigned()modifier. Actually, this were only supported on MySQL: