Skip to content

Commit

Permalink
fix: max string length resolution in AbstractPlatform::getEnumDeclara…
Browse files Browse the repository at this point in the history
…tionSQL()
  • Loading branch information
David Kurka committed Nov 1, 2024
1 parent 604277e commit a50c23f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ public function getEnumDeclarationSQL(array $column): string
throw ColumnValuesRequired::new($this, 'ENUM');
}

return $this->getStringTypeDeclarationSQL(['length' => max(...array_map(mb_strlen(...), $column['values']))]);
$length = count($column['values']) > 1
? max(...array_map(mb_strlen(...), $column['values']))
: mb_strlen($column['values'][key($column['values'])]);

Check failure on line 214 in src/Platforms/AbstractPlatform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (PHP: 8.3)

Function key() should not be referenced via a fallback global name, but via a use statement.

return $this->getStringTypeDeclarationSQL(['length' => $length]);
}

/**
Expand Down

0 comments on commit a50c23f

Please sign in to comment.