use of liquibase.datatype.core.ClobType in project liquibase by liquibase.
the class AbstractIntegrationTest method testInsertLongClob.
@Test
public void testInsertLongClob() {
assumeNotNull(this.getDatabase());
DatabaseChangeLog longClobChangelog = new DatabaseChangeLog();
ChangeSet longClobInsert = new ChangeSet(longClobChangelog);
ColumnConfig clobColumn = new ColumnConfig();
clobColumn.setName("clobColumn");
clobColumn.setType(LoadDataChange.LOAD_DATA_TYPE.CLOB.name());
// Oracle database only allows string values of up to 4000 characters
// so we test that the CLOB insertion is actually done as a CLOB in the JDBC statement
StringBuilder longClobString = new StringBuilder(4001);
for (int i = 0; i < 4001; i++) {
longClobString.append('a');
}
clobColumn.setValue(longClobString.toString());
CreateTableStatement clobTableCreator = new CreateTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), "tableWithClob");
clobTableCreator.addColumn("clobColumn", new ClobType());
InsertExecutablePreparedStatement insertStatement = new InsertExecutablePreparedStatement(database, database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), "tableWithClob", Arrays.asList(clobColumn), longClobInsert, Scope.getCurrentScope().getResourceAccessor());
try {
database.execute(new SqlStatement[] { clobTableCreator, insertStatement }, new ArrayList<>());
} catch (LiquibaseException ex) {
ex.printStackTrace();
fail("Long clob insertion failed!");
}
}
use of liquibase.datatype.core.ClobType in project liquibase by liquibase.
the class ClobTypeTest method mssqlEscapedNTextToNVarcharNoConvertTest.
@Test
public void mssqlEscapedNTextToNVarcharNoConvertTest() throws Exception {
Scope.child(GlobalConfiguration.CONVERT_DATA_TYPES.getKey(), false, () -> {
ClobType ct = new ClobType();
ct.finishInitialization("[NText]");
DatabaseDataType dbType = ct.toDatabaseDataType(new MSSQLDatabase());
assertEquals("nvarchar (max)", dbType.getType());
});
}
use of liquibase.datatype.core.ClobType in project liquibase by liquibase.
the class ClobTypeTest method mssqlEscapedTextToVarcharTest.
@Test
public void mssqlEscapedTextToVarcharTest() throws Exception {
Scope.child(GlobalConfiguration.CONVERT_DATA_TYPES.getKey(), true, () -> {
ClobType ct = new ClobType();
ct.finishInitialization("[Text]");
DatabaseDataType dbType = ct.toDatabaseDataType(new MSSQLDatabase());
assertEquals("varchar (max)", dbType.getType());
});
}
use of liquibase.datatype.core.ClobType in project liquibase by liquibase.
the class ClobTypeTest method mssqlEscapedTextToVarcharNoConvertTest.
@Test
public void mssqlEscapedTextToVarcharNoConvertTest() throws Exception {
Scope.child(GlobalConfiguration.CONVERT_DATA_TYPES.getKey(), false, () -> {
ClobType ct = new ClobType();
ct.finishInitialization("[Text]");
DatabaseDataType dbType = ct.toDatabaseDataType(new MSSQLDatabase());
assertEquals("varchar (max)", dbType.getType());
});
}
use of liquibase.datatype.core.ClobType in project liquibase by liquibase.
the class ClobTypeTest method mssqlTextToVarcharTest.
@Test
public void mssqlTextToVarcharTest() throws Exception {
Scope.child(GlobalConfiguration.CONVERT_DATA_TYPES.getKey(), true, () -> {
ClobType ct = new ClobType();
ct.finishInitialization("Text");
DatabaseDataType dbType = ct.toDatabaseDataType(new MSSQLDatabase());
assertEquals("varchar (max)", dbType.getType());
});
}
Aggregations