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

The following examples show how to use com.alibaba.druid.wall.spi.WallVisitorUtils. 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 File: DruidSelectParser.java    From Mycat2 with 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 File: OrVisitor.java    From baymax with 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 File: RouterUtil.java    From Mycat2 with 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 File: RouterUtil.java    From Mycat2 with 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 File: BooleanUtil.java    From baymax with 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 File: BooleanUtil.java    From baymax with 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 File: RouterUtil.java    From dble with 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 File: RouterUtil.java    From dble with 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);
}