Merge pull request #361 from limingxinleo/db

Fixed command `db:model` not work in mysql 8.
This commit is contained in:
李铭昕 2019-08-09 12:53:57 +08:00 committed by GitHub
commit 49bc42f364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,8 @@
## Fixed
- [#361](https://github.com/hyperf-cloud/hyperf/pull/361) Fixed command `db:model` not work in mysql 8.
# v1.0.10 - 2019-08-09
## Added

View File

@ -139,7 +139,7 @@ class ModelCommand extends Command
{
$builder = $this->getSchemaBuilder($option->getPool());
$table = Str::replaceFirst($option->getPrefix(), '', $table);
$columns = $builder->getColumnTypeListing($table);
$columns = $this->formatColumns($builder->getColumnTypeListing($table));
$project = new Project();
$class = $project->namespace($option->getPath()) . Str::studly($table);
@ -167,6 +167,16 @@ class ModelCommand extends Command
$this->output->writeln(sprintf('<info>Model %s was created.</info>', $class));
}
/**
* Format column's key to lower case.
*/
protected function formatColumns(array $columns): array
{
return array_map(function ($item) {
return array_change_key_case($item, CASE_LOWER);
}, $columns);
}
protected function getColumns($className, $columns, $forceCasts): array
{
/** @var Model $model */