Merge pull request #1531 from jamesagnew/dm-handle-jdbc-type-clob

Add case for handling JDBC type CLOB in JdbcUtils.
This commit is contained in:
Diederik Muylwyk 2019-10-08 14:37:09 -04:00 committed by GitHub
commit a4c9258d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -235,6 +235,8 @@ public class JdbcUtils {
return new ColumnType(BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP, length);
case Types.BLOB:
return new ColumnType(BaseTableColumnTypeTask.ColumnTypeEnum.BLOB, length);
case Types.CLOB:
return new ColumnType(BaseTableColumnTypeTask.ColumnTypeEnum.CLOB, length);
default:
throw new IllegalArgumentException("Don't know how to handle datatype " + dataType + " for column " + theColumnName + " on table " + theTableName);
}

View File

@ -9,7 +9,28 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.*;
public class ModifyColumnTest extends BaseTest {
@Test
public void testColumnWithJdbcTypeClob() throws SQLException {
executeSql("create table SOMETABLE (TEXTCOL clob)");
ModifyColumnTask task = new ModifyColumnTask();
task.setTableName("SOMETABLE");
task.setColumnName("TEXTCOL");
task.setColumnType(AddColumnTask.ColumnTypeEnum.STRING);
task.setNullable(true);
task.setColumnLength(250);
getMigrator().addTask(task);
getMigrator().migrate();
assertEquals(new JdbcUtils.ColumnType(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 250), JdbcUtils.getColumnType(getConnectionProperties(), "SOMETABLE", "TEXTCOL"));
assertEquals(1, task.getExecutedStatements().size());
// Make sure additional migrations don't crash
getMigrator().migrate();
getMigrator().migrate();
}
@Test
public void testColumnAlreadyExists() throws SQLException {