Browse Source

Reset base column type when column type is changed.

ADmad 2 years ago
parent
commit
8b35c64192

+ 2 - 0
src/Database/Schema/TableSchema.php

@@ -385,6 +385,8 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface
         $this->_columns[$name]['type'] = $type;
         $this->_typeMap[$name] = $type;
 
+        unset($this->_columns[$name]['baseType']);
+
         return $this;
     }
 

+ 3 - 0
tests/TestCase/Database/Schema/TableSchemaTest.php

@@ -170,8 +170,11 @@ class TableSchemaTest extends TestCase
             'null' => false,
         ]);
         $this->assertSame('string', $table->getColumnType('title'));
+        $this->assertSame('string', $table->baseColumnType('title'));
+
         $table->setColumnType('title', 'json');
         $this->assertSame('json', $table->getColumnType('title'));
+        $this->assertSame('json', $table->baseColumnType('title'));
     }
 
     /**