use of com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement in project druid by alibaba.
the class MySqlAlterTableTest_40_change method test_alter_constraint.
public void test_alter_constraint() throws Exception {
String sql = "alter table sdfwef change column a c int";
MySqlStatementParser parser = new MySqlStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
parser.match(Token.EOF);
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
stmt.accept(visitor);
// System.out.println("Tables : " + visitor.getTables());
// System.out.println("fields : " + visitor.getColumns());
// System.out.println("coditions : " + visitor.getConditions());
// System.out.println("orderBy : " + visitor.getOrderByColumns());
Assert.assertEquals("ALTER TABLE sdfwef\n" + "\tCHANGE COLUMN a c int", SQLUtils.toMySqlString(stmt));
Assert.assertEquals("alter table sdfwef\n" + "\tchange column a c int", SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION));
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(1, visitor.getColumns().size());
assertTrue(isRenameColumn((SQLAlterTableStatement) stmt));
}
Aggregations