Skip to content

Commit

Permalink
修正
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Aug 16, 2024
1 parent ca1f2ef commit d68e185
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/db/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,18 @@ public function fieldCase(array $info): array
*/
protected function getFieldType(string $type): string
{
// 将字段类型转换为小写以进行比较
$type = strtolower($type);

return match (true) {
str_starts_with($type, 'set') => 'set',
str_starts_with($type, 'enum') => 'enum',
str_starts_with($type, 'bigint') => 'bigint',
preg_match('/(double|float|decimal|real|numeric)/i', $type) => 'float',
preg_match('/(int|serial|bit)/i', $type) => 'int',
str_contains($type, 'float') || str_contains($type, 'double') ||
str_contains($type, 'decimal') || str_contains($type, 'real') ||
str_contains($type, 'numeric') => 'float',
str_contains($type, 'int') || str_contains($type, 'serial') ||
str_contains($type, 'bit') => 'int',
str_contains($type, 'bool') => 'bool',
str_starts_with($type, 'timestamp') => 'timestamp',
str_starts_with($type, 'datetime') => 'datetime',
Expand Down

0 comments on commit d68e185

Please sign in to comment.