-
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
[5.2] Add "Generated Columns" support to MySQL schema grammar #13430
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ class MySqlGrammar extends Grammar | |
* | ||
* @var array | ||
*/ | ||
protected $modifiers = ['Unsigned', 'Charset', 'Collate', 'Nullable', 'Default', 'Increment', 'Comment', 'After', 'First']; | ||
protected $modifiers = ['VirtualAs', 'StoredAs', 'Unsigned', 'Charset', 'Collate', 'Nullable', 'Default', 'Increment', 'Comment', 'After', 'First']; | ||
|
||
/** | ||
* The possible column serials. | ||
|
@@ -624,6 +624,34 @@ protected function typeMacAddress(Fluent $column) | |
return 'varchar(17)'; | ||
} | ||
|
||
/** | ||
* Get the SQL for a generated virtual column modifier. | ||
* | ||
* @param \Illuminate\Database\Schema\Blueprint $blueprint | ||
* @param \Illuminate\Support\Fluent $column | ||
* @return string|null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. void cannot be unioned with anything There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate on that ? References ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. laravel considers void to mean garbage, not "no return" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is possible that definition is changing in php 7.1, but for now, we're sticking with our original definition |
||
*/ | ||
protected function modifyVirtualAs(Blueprint $blueprint, Fluent $column) | ||
{ | ||
if (! is_null($column->virtualAs)) { | ||
return " as ({$column->virtualAs})"; | ||
} | ||
} | ||
|
||
/** | ||
* Get the SQL for a generated stored column modifier. | ||
* | ||
* @param \Illuminate\Database\Schema\Blueprint $blueprint | ||
* @param \Illuminate\Support\Fluent $column | ||
* @return string|null | ||
*/ | ||
protected function modifyStoredAs(Blueprint $blueprint, Fluent $column) | ||
{ | ||
if (! is_null($column->storedAs)) { | ||
return " as ({$column->storedAs}) stored"; | ||
} | ||
} | ||
|
||
/** | ||
* Get the SQL for an unsigned column modifier. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make sense to make this statement multiline