-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[6.x] Wrap MySQL default values in parentheses #29878
Conversation
wrap default values in parentheses and update tests
No, I think the plan is just, on release day, it will be decided if patch or minor version is bumped. Usually, minor version I guess. |
Next release will be v6.1.0. |
and patch releases will just happen Ad Hoc outside of normal release days? |
I don't think so? |
Patch releases will only happen if there's a critical bug to be fixed, or there happened to be no new features warranting a minor bump on release day. |
Yup, that's what I meant. 👍 |
@browner12 @GrahamCampbell we've decided to evaluate every release if there's going to be a patch or minor release to properly handle SemVer. |
Right, so as I thought. :P
|
Heads up that this broke one of my migrations after updating from 6.0.1 to 6.0.2. I had an old migration class with:
This broke because of the PR. I received the error:
|
thanks for the insight Jeffrey. what version of MySQL are you on? maybe we'll have to be selective about what types of columns we apply the parentheses to. |
FYI, I've just run this exact query ( |
so the statement executed successfully, but apparently it set the default value to (_utf8mb4'0') |
experienced this on mysql 5.7.24 |
@taylorotwell I'm thinking we should revert this for now, because it appears MySQL prior to 8.0.13 cannot handle "expressions" as their default value. https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-types-defaults-explicit-old
What I am going to propose is a new method on the schema grammar called |
Also experiencing this issue with defaults on integers. Just changed the MySqlGrammer back to ' return ' default '.$this->getDefaultValue($column->default);' as a temp fix. |
This reverts commit 2f20d88.
An extra parameter could also do the job. function default($value, $expression = false); |
Laravel is usually very anti After digging into the source, I found out it's actually currently possible to add expressions as a default value. I've sent a PR into the Docs to help explain how to use it: |
Does this fix adding default values for boolean columns. On Laravel 6.0.3 and it still fails. Can you post an example of how to set default value for a |
this PR was reverted due to it breaking people still on MySQL 5. Boolean columns have always worked $table->boolean('checked')->default(true); Here is the code that makes it work. You can see it's converting the boolean to an integer, since we store boolean values as TINYINTs in the database anyway. |
OK, looks like this issue is not available on the latest version of Lumen yet. I did try to update my lumen project by running |
Prior to MySQL 8.0.13, types of
Blob
,Text
,Geometry
, andJSON
could not be assigned default values.This made JSON fields cast as Collections annoying to handle when the value was
null
.As of MySQL 8.0.13, we can now add default values to these fields, but a minor change needs to be made in the grammar. These fields can be assigned a default value only if the value is written as an expression, even if the expression value is a literal.
This will not work:
but this will:
Originally I was going to conditionally check for the field type and only apply the parentheses for the required types, but that seemed like overkill. Only if there were performance or other implications for making every default value an expression would I think we would need to do that.
I won't presume to know how the other DB engines handle this, but there's a decent chance these changes will need to be made to them as well.
On a side note, now that we've switched to SemVer, do we need to indicate in our PRs if we think they are minor or patch commits?