Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ColumnDefinitionParser #922

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert some changes
  • Loading branch information
Tigrov committed Jan 19, 2025
commit 2ff7555be953909ea267f50ef2f98768cd141ec3
23 changes: 5 additions & 18 deletions src/QueryBuilder/AbstractColumnDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ protected function buildType(ColumnInterface $column): string
{
$dbType = $this->getDbType($column);

if (empty($dbType) || $dbType[-1] === ')' || !$this->isAllowSize($dbType)) {
if (empty($dbType)
|| $dbType[-1] === ')'
|| !in_array(strtolower($dbType), static::TYPES_WITH_SIZE, true)
) {
return $dbType;
}

Expand All @@ -266,7 +269,7 @@ protected function buildType(ColumnInterface $column): string

$scale = $column->getScale();

if ($scale === null || !$this->isAllowScale($dbType)) {
if ($scale === null || !in_array(strtolower($dbType), static::TYPES_WITH_SCALE, true)) {
return "$dbType($size)";
}

Expand Down Expand Up @@ -305,20 +308,4 @@ protected function getDefaultUuidExpression(): string
{
return '';
}

/**
* Check if the database column type allow scale specification.
*/
protected function isAllowScale(string $dbType): bool
{
return in_array(strtolower($dbType), static::TYPES_WITH_SCALE, true);
}

/**
* Check if the database column type allow size specification.
*/
protected function isAllowSize(string $dbType): bool
{
return in_array(strtolower($dbType), static::TYPES_WITH_SIZE, true);
}
}
Loading