From 9ea65364e21b73ce464b4f3498e3365ef501bccf Mon Sep 17 00:00:00 2001 From: heui Date: Wed, 22 Oct 2025 10:28:09 +0800 Subject: [PATCH] Fix Decimal Column Definition Issue When Scale is 0 In CakePHP's MySQL adapter, when defining a Decimal column with scale set to 0 (e.g. DECIMAL(65,0) or DECIMAL(10,0)), the generated SQL definition was missing precision information. Specifically, when users need to create a DECIMAL(65) column (precision=65, scale=0), due to the condition check $column->getScale() returning 0, which is treated as false in boolean context, the entire condition $column->getPrecision() && $column->getScale() evaluates to false, causing the precision and scale definition to be skipped. --- src/Phinx/Db/Adapter/MysqlAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index 419156875..0dfbb2e37 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -1355,7 +1355,7 @@ protected function getColumnSqlDefinition(Column $column): string $sqlType = $this->getSqlType($column->getType(), $column->getLimit()); $def = strtoupper($sqlType['name']); } - if ($column->getPrecision() && $column->getScale()) { + if ($column->getPrecision() && $column->getScale() !== null) { $def .= '(' . $column->getPrecision() . ',' . $column->getScale() . ')'; } elseif (isset($sqlType['limit'])) { $def .= '(' . $sqlType['limit'] . ')';