Search in sources :

Example 16 with SQLOrderBy

use of com.alibaba.druid.sql.ast.SQLOrderBy in project druid by alibaba.

the class WallVisitorUtils method checkSqlExpr.

public static boolean checkSqlExpr(SQLExpr x) {
    // check groupby, orderby, limit
    if (x == null) {
        return false;
    }
    SQLObject obj = x;
    for (; ; ) {
        SQLObject parent = obj.getParent();
        if (parent == null) {
            return false;
        }
        if (parent instanceof SQLSelectGroupByClause) {
            return true;
        } else if (parent instanceof SQLOrderBy) {
            return true;
        } else if (parent instanceof SQLLimit) {
            return true;
        } else if (parent instanceof MySqlOrderingExpr) {
            return true;
        }
        obj = parent;
    }
}
Also used : SQLOrderBy(com.alibaba.druid.sql.ast.SQLOrderBy) MySqlOrderingExpr(com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr) SQLObject(com.alibaba.druid.sql.ast.SQLObject) SQLLimit(com.alibaba.druid.sql.ast.SQLLimit)

Aggregations

SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)16 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)8 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)6 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)6 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)5 SQLSelectItem (com.alibaba.druid.sql.ast.statement.SQLSelectItem)5 SQLSubqueryTableSource (com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource)5 SQLTableSource (com.alibaba.druid.sql.ast.statement.SQLTableSource)4 ParserException (com.alibaba.druid.sql.parser.ParserException)4 SQLOver (com.alibaba.druid.sql.ast.SQLOver)3 SQLBinaryOperator (com.alibaba.druid.sql.ast.expr.SQLBinaryOperator)3 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)3 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)3 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)3 SQLSelectOrderByItem (com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem)3 DB2SelectQueryBlock (com.alibaba.druid.sql.dialect.db2.ast.stmt.DB2SelectQueryBlock)3 OracleSelect (com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect)3 SQLServerSelectQueryBlock (com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock)3 SQLAllColumnExpr (com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr)2 SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)2