Java Code Examples for com.alibaba.druid.wall.spi.WallVisitorUtils

The following examples show how to use com.alibaba.druid.wall.spi.WallVisitorUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Mycat2   Source File: DruidSelectParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean isConditionAlwaysTrue(SQLStatement statement) {
	SQLSelectStatement selectStmt = (SQLSelectStatement)statement;
	SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
	if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
		MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
		SQLExpr expr = mysqlSelectQuery.getWhere();

		Object o = WallVisitorUtils.getValue(expr);
		if(Boolean.TRUE.equals(o)) {
			return true;
		}
		return false;
	} else {//union
		return false;
	}

}
 
Example 2
Source Project: baymax   Source File: OrVisitor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean visit(SQLBinaryOpExpr x) {
       x.getLeft().setParent(x);
       x.getRight().setParent(x);

       if (!SQLBinaryOperator.BooleanOr.equals(x.getOperator())) {
           return super.visit(x);
       }

       // true * (a and b) = (a and b) 没有意义
       if (Boolean.TRUE.equals(WallVisitorUtils.getValue(x))) {
           return false;
       }

       // 这是一个Or表达式 这个or代表的集合是要和当前已经获取的Condition列表 相乘的.
       orEntity.add(new OrEntity(this, x));
       return false;
   }
 
Example 3
Source Project: Mycat2   Source File: RouterUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 判断条件是否永真
 * @param expr
 * @return
 */
public static boolean isConditionAlwaysTrue(SQLExpr expr) {
	Object o = WallVisitorUtils.getValue(expr);
	if(Boolean.TRUE.equals(o)) {
		return true;
	}
	return false;
}
 
Example 4
Source Project: Mycat2   Source File: RouterUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 判断条件是否永假的
 * @param expr
 * @return
 */
public static boolean isConditionAlwaysFalse(SQLExpr expr) {
	Object o = WallVisitorUtils.getValue(expr);
	if(Boolean.FALSE.equals(o)) {
		return true;
	}
	return false;
}
 
Example 5
Source Project: baymax   Source File: BooleanUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 判断条件是否永假的
 * @param expr
 * @return
 */
public static boolean isConditionAlwaysFalse(SQLExpr expr) {
    Object o = WallVisitorUtils.getValue(expr);
    if(Boolean.FALSE.equals(o)) {
        return true;
    }
    return false;
}
 
Example 6
Source Project: baymax   Source File: BooleanUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isConditionAlwaysTrue(SQLExpr expr) {
    Object o = WallVisitorUtils.getValue(expr);
    if(Boolean.TRUE.equals(o)) {
        return true;
    }
    return false;
}
 
Example 7
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static boolean isConditionAlwaysTrue(SQLExpr expr) {
    Object o = WallVisitorUtils.getValue(expr);
    return Boolean.TRUE.equals(o);
}
 
Example 8
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static boolean isConditionAlwaysFalse(SQLExpr expr) {
    Object o = WallVisitorUtils.getValue(expr);
    return Boolean.FALSE.equals(o);
}