From ea644496586f013d773de66402c6169ea73b1a41 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Sat, 25 Oct 2025 16:25:18 +0000 Subject: [PATCH 1/2] Add tests for decimal scale fix Signed-off-by: Matthew Peveler --- tests/Phinx/Db/Adapter/MysqlAdapterTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 24b2d24e8..93dce12b7 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -2727,6 +2727,21 @@ public function testCreateTableWithPrecisionCurrentTimestamp() $this->assertEqualsIgnoringCase('CURRENT_TIMESTAMP(3)', $colDef['COLUMN_DEFAULT']); } + public function testCreateTableWithZeroScale(): void + { + $this->adapter->connect(); + $table = new Table('test_table', ['id' => false], $this->adapter); + $table + ->addColumn('col_1', 'decimal', ['null' => false, 'precision' => 10, 'scale' => 0]) + ->create(); + + $columns = $table->getColumns(); + $this->assertCount(1, $columns); + $this->assertSame('col_1', $columns[0]->getName()); + $this->assertSame(10, $columns[0]->getPrecision()); + $this->assertSame(0, $columns[0]->getScale()); + } + public function pdoAttributeProvider() { return [ From 95d6923c56420f7a66020a2001c3dccc14f8aaff Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Sat, 25 Oct 2025 19:14:13 +0000 Subject: [PATCH 2/2] actually make test work --- tests/Phinx/Db/Adapter/MysqlAdapterTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 93dce12b7..ab98cc51f 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -2732,13 +2732,13 @@ public function testCreateTableWithZeroScale(): void $this->adapter->connect(); $table = new Table('test_table', ['id' => false], $this->adapter); $table - ->addColumn('col_1', 'decimal', ['null' => false, 'precision' => 10, 'scale' => 0]) + ->addColumn('col_1', 'decimal', ['null' => false, 'precision' => 15, 'scale' => 0]) ->create(); $columns = $table->getColumns(); $this->assertCount(1, $columns); $this->assertSame('col_1', $columns[0]->getName()); - $this->assertSame(10, $columns[0]->getPrecision()); + $this->assertSame(15, $columns[0]->getPrecision()); $this->assertSame(0, $columns[0]->getScale()); }