Search in sources :

Example 1 with MySqlExpr

use of com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExpr in project druid by alibaba.

the class SchemaStatVisitor method visit.

public boolean visit(SQLOrderBy x) {
    final SQLASTVisitor orderByVisitor = createOrderByVisitor(x);
    SQLSelectQueryBlock query = null;
    if (x.getParent() instanceof SQLSelectQueryBlock) {
        query = (SQLSelectQueryBlock) x.getParent();
    }
    if (query != null) {
        for (SQLSelectOrderByItem item : x.getItems()) {
            SQLExpr expr = item.getExpr();
            if (expr instanceof SQLIntegerExpr) {
                int intValue = ((SQLIntegerExpr) expr).getNumber().intValue() - 1;
                if (intValue < query.getSelectList().size()) {
                    SQLSelectItem selectItem = query.getSelectList().get(intValue);
                    selectItem.getExpr().accept(orderByVisitor);
                }
            } else if (expr instanceof MySqlExpr || expr instanceof OracleExpr) {
                continue;
            }
        }
    }
    x.accept(orderByVisitor);
    return true;
}
Also used : MySqlExpr(com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExpr) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr) OracleExpr(com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleExpr) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)1 MySqlExpr (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExpr)1 OracleExpr (com.alibaba.druid.sql.dialect.oracle.ast.expr.OracleExpr)1