Skip to content

Commit c7ff3d9

Browse files
committed
change genrate entity null if
1 parent c17eabf commit c7ff3d9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/Model/Dao/SchemaDao.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ public function getColumnsSchema(string $pool, string $table): array
3131
{
3232
$schemaBuilder = Builder::new($pool);
3333
$columnsDetail = $schemaBuilder->getColumnsDetail($table);
34+
3435
foreach ($columnsDetail as &$column) {
3536
$originPHPType = $schemaBuilder->convertType($column['type']);
3637

3738
// if is null able
38-
$nullable = ($column['nullable'] === 'YES' || $column['default'] === null);
39+
$nullable = $column['nullable'] === 'YES';
3940
$column['is_nullable'] = $nullable;
4041

4142
$column['phpType'] = $originPHPType . ($nullable ? '|null' : '');
4243
$column['originPHPType'] = $originPHPType;
4344
}
4445
unset($column);
46+
4547
return $columnsDetail;
4648
}
4749

src/Model/Logic/EntityLogic.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ private function generateEntity(
144144
$gen = new FileGenerator($config);
145145

146146
$fileExists = file_exists($file);
147+
147148
if (!$fileExists &&
148149
!$isConfirm &&
149150
!ConsoleHelper::confirm("generate entity $file, Ensure continue?", true)) {
150151
output()->writeln(' Quit, Bye!');
151152
return;
152153
}
153-
if ($fileExists && !ConsoleHelper::confirm(" entity $file already exists, Ensure continue?", false)) {
154+
if ($fileExists &&
155+
!$isConfirm &&
156+
!ConsoleHelper::confirm(" entity $file already exists, Ensure continue?", false)) {
154157
output()->writeln(' Quit, Bye!');
155158
return;
156159
}
@@ -159,6 +162,7 @@ private function generateEntity(
159162
output()->colored(" Generate entity $file OK!", 'success');
160163
return;
161164
}
165+
162166
output()->colored(" Generate entity $file Fail!", 'error');
163167
}
164168

src/Model/Logic/MigrateLogic.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private function getSafeMigrationData(callable $callback): array
460460
if (stripos($message, MigrateDao::tableName()) === false) {
461461
output()->warning($message);
462462
}
463-
return null;
463+
return [];
464464
}
465465
return $data;
466466
}
@@ -572,11 +572,10 @@ private function runMigration(Builder $schema, string $migrateName, string $meth
572572
}
573573
};
574574

575-
$schema->grammar->supportsSchemaTransactions()
576-
?
577-
$schema->getConnection()->transaction($callback)
578-
:
575+
$schema->grammar->supportsSchemaTransactions() ?
576+
$schema->getConnection()->transaction($callback) :
579577
$callback();
578+
580579
return true;
581580
}
582581

0 commit comments

Comments
 (0)