use of com.alibaba.druid.sql.ast.statement.SQLCreateIndexStatement in project druid by alibaba.
the class SQLServerCreateIndexTest_2 method test_0.
public void test_0() throws Exception {
String sql = "CREATE UNIQUE CLUSTERED INDEX Idx1 ON t1(c);";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLCreateIndexStatement stmt = (SQLCreateIndexStatement) statementList.get(0);
Assert.assertEquals(1, statementList.size());
//
Assert.assertEquals(//
"CREATE UNIQUE CLUSTERED INDEX Idx1 ON t1 (c);", SQLUtils.toSQLString(stmt, JdbcConstants.ORACLE));
SQLServerSchemaStatVisitor visitor = new SQLServerSchemaStatVisitor();
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(1, visitor.getTables().size());
Assert.assertEquals(1, visitor.getColumns().size());
Assert.assertEquals(0, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t1")));
Assert.assertTrue(visitor.getColumns().contains(new Column("t1", "c")));
}
Aggregations