Skip to content

Commit f40628a

Browse files
committed
changeColumn() defaulting.
1 parent c8bd7f1 commit f40628a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/TestCase/Db/Adapter/MysqlAdapterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,8 @@ public function testChangeColumnPreservesDefaultValue()
961961
$table->addColumn('column1', 'string', ['default' => 'original_default', 'null' => false, 'limit' => 100])
962962
->save();
963963

964-
// Change only the null property, default should be preserved
965-
$table->changeColumn('column1', 'string', ['null' => true])->save();
964+
// Use updateColumn which preserves by default
965+
$table->updateColumn('column1', 'string', ['null' => true])->save();
966966

967967
$rows = $this->adapter->fetchAll('SHOW COLUMNS FROM t');
968968
$this->assertEquals('original_default', $rows[1]['Default']);
@@ -976,8 +976,8 @@ public function testChangeColumnPreservesDefaultValueWithDifferentType()
976976
$table->addColumn('column1', 'integer', ['default' => 42, 'null' => false])
977977
->save();
978978

979-
// Change type to biginteger, default should be preserved
980-
$table->changeColumn('column1', 'biginteger', [])->save();
979+
// Use updateColumn to preserve default when changing type
980+
$table->updateColumn('column1', 'biginteger', [])->save();
981981

982982
$rows = $this->adapter->fetchAll('SHOW COLUMNS FROM t');
983983
$this->assertEquals('42', $rows[1]['Default']);
@@ -1016,8 +1016,8 @@ public function testChangeColumnWithNullTypePreservesType()
10161016
$table->addColumn('column1', 'string', ['default' => 'test', 'limit' => 100])
10171017
->save();
10181018

1019-
// Pass null as type to preserve existing type
1020-
$table->changeColumn('column1', null, ['null' => true])->save();
1019+
// Use updateColumn with null type to preserve everything
1020+
$table->updateColumn('column1', null, ['null' => true])->save();
10211021

10221022
$rows = $this->adapter->fetchAll('SHOW COLUMNS FROM t');
10231023
$this->assertEquals('varchar(100)', $rows[1]['Type']);

0 commit comments

Comments
 (0)