Skip to content

Commit

Permalink
0001389: Postgres alter to add a default varchar value to a column wi…
Browse files Browse the repository at this point in the history
…thout a default value fails
  • Loading branch information
chenson42 committed Aug 16, 2013
1 parent a2b5047 commit e14b289
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,28 @@ public void testTableRebuild() throws Exception {
Assert.assertEquals(1, template.queryForLong(String.format("select count(*) from %s%s%s", delimiter, tableFromDatabase.getName(), delimiter)));

}

@Test
public void testAddDefaultValueToVarcharColumn() throws Exception {
Table table = new Table("TEST_ADD_DEFAULT");
table.addColumn(new Column("ID1", true));
table.getColumnWithName("ID1").setTypeCode(Types.INTEGER);
table.getColumnWithName("ID1").setRequired(true);

table.addColumn(new Column("NOTES"));
table.getColumnWithName("NOTES").setTypeCode(Types.VARCHAR);
table.getColumnWithName("NOTES").setSize("20");

dropCreateAndThenReadTable(table);

final String DEFAULT_VALUE = "SOMETHING";
table.getColumnWithName("NOTES").setDefaultValue(DEFAULT_VALUE);

platform.alterTables(false, table);
Table tableFromDatabase = platform.getTableFromCache(table.getName(), true);

Assert.assertEquals(DEFAULT_VALUE, tableFromDatabase.getColumnWithName("NOTES").getDefaultValue());
}

@Test
public void testExportDefaultValueWithUnderscores() {
Expand Down

0 comments on commit e14b289

Please sign in to comment.