m_doubleColTableStep.getColumnOutline("value").setPrecision(100);
m_doubleColTableStep.getColumnOutline("value").setCaseInsensitive(Boolean.FALSE);
}
RelationalSchema schema = upgrade(m_doubleColTableStep, null, null);
Table table = schema.getTable(m_doubleColTableStep.getName());
assertNotNull(table);
assertEquals(2, table.getColumnCount());
table.setType(Table.MANAGED); // comes in as Table.EXTERNAL from DB
Column column0 = table.getColumn(0);
Column column1 = table.getColumn(1);
assertType(Primitive.INTEGER, column0.getType());
assertFalse(column0.isNullable());
assertType(from, column1.getType());
assertFalse(column1.isNullable());
column1.setType(from); // reset to proper type since this will be required further in test
StringBuffer buf = new StringBuffer(128);
ExecStep exec = new ExecStep();
SQLScript script = new SQLScript();
SQLStatement insert = new SQLStatement();
buf.append("insert into ");
buf.append(table.getFullName(null));
buf.append(" (");
buf.append(column0.getName());
buf.append(", ");
buf.append(column1.getName());
buf.append(") values (1, ");
m_adapter.appendLiteral(buf, column1, seed);
buf.append(")");
insert.setSQL(buf.toString()); // ensure at least one row in table
script.addStatement(insert);
exec.getScriptHolder().addScript(script);
upgrade(exec, null, null); // insert a record into the table to test altering an actual value
AlterColumnStep step = new AlterColumnStep();
ColumnOutline outline = new ColumnOutline("value");
outline.setType(to);
if (bToLOB)
{
outline.setAllocation(Column.LOCATOR);
}
else
{
outline.setAllocation( // set Column.FIXED/Column.VARYING as per original column
(column1.getAllocation() == Column.LOCATOR) ? Column.VARYING : column1.getAllocation());
}
outline.setNullable(Boolean.FALSE);
if (to == Primitive.BINARY || to == Primitive.STRING)
{
outline.setPrecision(100);
outline.setCaseInsensitive(Boolean.FALSE);
}
step.setOutline(outline);
step.setTableName(m_doubleColTableStep.getName());
try
{
schema = upgrade(step, schema, null);
}
catch (RuntimeException e)
{
throw new RuntimeException("Error: alter column from: " + from + " to: " + to, e);
}
table = schema.getTable(m_doubleColTableStep.getName());
assertNotNull(table);
assertEquals(2, table.getColumnCount());
column1 = table.getColumn(1);
assertType(to, column1.getType());
assertFalse(column1.isNullable());
DropTableStep drop = new DropTableStep();
table.setType(Table.MANAGED); // comes in as Table.EXTERNAL from DB
drop.setName(m_doubleColTableStep.getName());
upgrade(drop, schema, null);
}