Browse Source

Merge pull request #17363 from cakephp/tableschema-basecolumntype

Reset base column type when column type is changed.
Mark Story 2 years ago
parent
commit
400100917a

+ 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'));
     }
 
     /**