use of com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr in project druid by alibaba.
the class Resolve_AllColumn_Test method test_resolve.
public void test_resolve() throws Exception {
SchemaRepository repository = new SchemaRepository(DbType.mysql);
repository.acceptDDL("create table t_emp(emp_id bigint, name varchar(20));");
SQLStatement stmt = SQLUtils.parseSingleMysqlStatement("select * from t_emp");
repository.resolve(stmt, SchemaResolveVisitor.Option.ResolveAllColumn);
assertEquals("SELECT emp_id, name\n" + "FROM t_emp", stmt.toString());
SQLSelectQueryBlock queryBlock = ((SQLSelectStatement) stmt).getSelect().getQueryBlock();
SQLIdentifierExpr expr = (SQLIdentifierExpr) queryBlock.getSelectList().get(0).getExpr();
assertNotNull(expr.getResolvedColumn());
new SQLASTVisitorAdapter() {
public boolean visit(SQLSelectQueryBlock queryBlock) {
final List<SQLSelectItem> selectList = queryBlock.getSelectList();
for (int i = 0; i < selectList.size(); i++) {
final SQLSelectItem selectItem = selectList.get(i);
final SQLExpr expr = selectItem.getExpr();
if (expr instanceof SQLAllColumnExpr) {
} else if (expr instanceof SQLPropertyExpr && ((SQLPropertyExpr) expr).getName().equals("*")) {
}
}
return true;
}
};
}
Aggregations