mirror of
http://124.126.16.154:8888/singularity/hyperf-admin.git
synced 2026-01-15 05:35:08 +08:00
Merge pull request #11 from feraner/master
兼容 mysql8.0 table_type 是枚举类型bug
This commit is contained in:
@@ -296,13 +296,13 @@ class DevController extends AbstractController
|
|||||||
$ret = [];
|
$ret = [];
|
||||||
$ignores = ['id', 'create_at', 'update_at', 'is_deleted'];
|
$ignores = ['id', 'create_at', 'update_at', 'is_deleted'];
|
||||||
foreach ($schema as $item) {
|
foreach ($schema as $item) {
|
||||||
if (in_array($item['column_name'], $ignores)) {
|
if (in_array($item['COLUMN_NAME'], $ignores)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ret[] = [
|
$ret[] = [
|
||||||
'field' => $item['column_name'],
|
'field' => $item['COLUMN_NAME'],
|
||||||
'label' => $item['column_comment'],
|
'label' => $item['COLUMN_COMMENT'],
|
||||||
'type' => $this->transType($item['data_type']),
|
'type' => $this->transType($item['DATA_TYPE']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +316,10 @@ class DevController extends AbstractController
|
|||||||
return 'datetime';
|
return 'datetime';
|
||||||
case 'bigint':
|
case 'bigint':
|
||||||
return 'number';
|
return 'number';
|
||||||
|
case 'text':
|
||||||
|
return 'html';
|
||||||
|
case 'enum':
|
||||||
|
return 'radio';
|
||||||
default:
|
default:
|
||||||
return 'input';
|
return 'input';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ModelMaker extends AbstractMaker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$columns = array_values(array_filter(array_map(function ($item) {
|
$columns = array_values(array_filter(array_map(function ($item) {
|
||||||
if(in_array($item['column_name'], [
|
if(in_array($item['COLUMN_NAME'], [
|
||||||
'create_at',
|
'create_at',
|
||||||
'update_at',
|
'update_at',
|
||||||
'is_deleted',
|
'is_deleted',
|
||||||
@@ -30,7 +30,7 @@ class ModelMaker extends AbstractMaker
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item['column_name'];
|
return $item['COLUMN_NAME'];
|
||||||
}, $schema)));
|
}, $schema)));
|
||||||
$class_namespace = $this->pathToNamespace($path) . '\\' . Str::studly($database);
|
$class_namespace = $this->pathToNamespace($path) . '\\' . Str::studly($database);
|
||||||
$class_name = Str::studly($table);
|
$class_name = Str::studly($table);
|
||||||
@@ -68,10 +68,10 @@ class ModelMaker extends AbstractMaker
|
|||||||
|
|
||||||
protected function getProperty($column): array
|
protected function getProperty($column): array
|
||||||
{
|
{
|
||||||
$name = $column['column_name'];
|
$name = $column['COLUMN_NAME'];
|
||||||
$type = $this->formatPropertyType($column['data_type'], $column['cast'] ?? null);
|
$type = $this->formatPropertyType($column['DATA_TYPE'], $column['cast'] ?? null);
|
||||||
|
|
||||||
return [$name, $type, $column['column_comment']];
|
return [$name, $type, $column['COLUMN_COMMENT']];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatDatabaseType(string $type): ?string
|
protected function formatDatabaseType(string $type): ?string
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class TableSchema
|
|||||||
$builder = $this->getSchemaBuilder($pool);
|
$builder = $this->getSchemaBuilder($pool);
|
||||||
|
|
||||||
return $builder->getConnection()
|
return $builder->getConnection()
|
||||||
->select('select `column_name`, `data_type`, `column_comment` from information_schema.columns where `table_schema` = ? and `table_name` = ? order by ORDINAL_POSITION', [
|
->select('select `COLUMN_NAME`, `DATA_TYPE`, `COLUMN_COMMENT` from information_schema.COLUMNS where `TABLE_SCHEMA` = ? and `TABLE_NAME` = ? order by ORDINAL_POSITION', [
|
||||||
$database,
|
$database,
|
||||||
$table_name,
|
$table_name,
|
||||||
]);
|
]);
|
||||||
@@ -48,11 +48,11 @@ class TableSchema
|
|||||||
{
|
{
|
||||||
$builder = $this->getSchemaBuilder($pool);
|
$builder = $this->getSchemaBuilder($pool);
|
||||||
$ret = $builder->getConnection()
|
$ret = $builder->getConnection()
|
||||||
->select("select table_name from information_schema.tables where table_schema=? and table_type='base table';", [
|
->select("select TABLE_NAME from information_schema.tables where table_schema=? and table_type='BASE TABLE';", [
|
||||||
$database,
|
$database,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return array_column($ret ?? [], 'table_name');
|
return array_column($ret ?? [], 'TABLE_NAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tableDesign($pool, $database, $table_name)
|
public function tableDesign($pool, $database, $table_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user