mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 11:48:08 +08:00
Merge pull request #361 from limingxinleo/db
Fixed command `db:model` not work in mysql 8.
This commit is contained in:
commit
49bc42f364
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
## Fixed
|
## 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
|
# v1.0.10 - 2019-08-09
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
@ -139,7 +139,7 @@ class ModelCommand extends Command
|
|||||||
{
|
{
|
||||||
$builder = $this->getSchemaBuilder($option->getPool());
|
$builder = $this->getSchemaBuilder($option->getPool());
|
||||||
$table = Str::replaceFirst($option->getPrefix(), '', $table);
|
$table = Str::replaceFirst($option->getPrefix(), '', $table);
|
||||||
$columns = $builder->getColumnTypeListing($table);
|
$columns = $this->formatColumns($builder->getColumnTypeListing($table));
|
||||||
|
|
||||||
$project = new Project();
|
$project = new Project();
|
||||||
$class = $project->namespace($option->getPath()) . Str::studly($table);
|
$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));
|
$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
|
protected function getColumns($className, $columns, $forceCasts): array
|
||||||
{
|
{
|
||||||
/** @var Model $model */
|
/** @var Model $model */
|
||||||
|
Loading…
Reference in New Issue
Block a user