use of com.dangdang.ddframe.rdb.sharding.parser.result.merger.OrderByColumn.OrderByType in project sharding-jdbc by dangdangdotcom.
the class MySQLSelectVisitor method visit.
public boolean visit(final SQLOrderBy x) {
for (SQLSelectOrderByItem each : x.getItems()) {
SQLExpr expr = each.getExpr();
OrderByType orderByType = null == each.getType() ? OrderByType.ASC : OrderByType.valueOf(each.getType());
if (expr instanceof SQLIntegerExpr) {
getParseContext().addOrderByColumn(((SQLIntegerExpr) expr).getNumber().intValue(), orderByType);
} else if (expr instanceof SQLIdentifierExpr) {
getParseContext().addOrderByColumn(Optional.<String>absent(), ((SQLIdentifierExpr) expr).getName(), orderByType);
} else if (expr instanceof SQLPropertyExpr) {
SQLPropertyExpr sqlPropertyExpr = (SQLPropertyExpr) expr;
getParseContext().addOrderByColumn(Optional.of(sqlPropertyExpr.getOwner().toString()), sqlPropertyExpr.getName(), orderByType);
}
}
return super.visit(x);
}
use of com.dangdang.ddframe.rdb.sharding.parser.result.merger.OrderByColumn.OrderByType in project sharding-jdbc by dangdangdotcom.
the class MySQLSelectVisitor method visit.
/**
* 将GROUP BY列放入parseResult.
* 直接返回false,防止重复解析GROUP BY表达式.
*
* @param x GROUP BY 表达式
* @return false 停止遍历AST
*/
@Override
public boolean visit(final MySqlSelectGroupByExpr x) {
OrderByType orderByType = null == x.getType() ? OrderByType.ASC : OrderByType.valueOf(x.getType());
if (x.getExpr() instanceof SQLPropertyExpr) {
SQLPropertyExpr expr = (SQLPropertyExpr) x.getExpr();
getParseContext().addGroupByColumns(Optional.of(expr.getOwner().toString()), expr.getName(), orderByType);
} else if (x.getExpr() instanceof SQLIdentifierExpr) {
SQLIdentifierExpr expr = (SQLIdentifierExpr) x.getExpr();
getParseContext().addGroupByColumns(Optional.<String>absent(), expr.getName(), orderByType);
}
return super.visit(x);
}
Aggregations