Search in sources :

Example 1 with AstBooleanExpression

use of com.developmentontheedge.sql.model.AstBooleanExpression in project be5 by DevelopmentOnTheEdge.

the class FilterApplier method addWhere.

private void addWhere(AstWhere where, Map<ColumnRef, Object> conditions) {
    if (where.jjtGetNumChildren() != 0) {
        if (!AstFunNode.isFunction(DefaultParserContext.AND_LIT).test(where.child(0))) {
            AstFunNode and = DefaultParserContext.FUNC_AND.node();
            for (SimpleNode child : where.children()) and.addChild(child instanceof AstBooleanExpression ? new AstParenthesis(child) : child);
            where.removeChildren();
            where.addChild(and);
        }
        setConditions(where.child(0), conditions);
    } else if (conditions.size() > 1) {
        where.addChild(DefaultParserContext.FUNC_AND.node());
        setConditions(where.child(0), conditions);
    } else
        setConditions(where, conditions);
}
Also used : AstBooleanExpression(com.developmentontheedge.sql.model.AstBooleanExpression) AstFunNode(com.developmentontheedge.sql.model.AstFunNode) AstParenthesis(com.developmentontheedge.sql.model.AstParenthesis) SimpleNode(com.developmentontheedge.sql.model.SimpleNode)

Aggregations

AstBooleanExpression (com.developmentontheedge.sql.model.AstBooleanExpression)1 AstFunNode (com.developmentontheedge.sql.model.AstFunNode)1 AstParenthesis (com.developmentontheedge.sql.model.AstParenthesis)1 SimpleNode (com.developmentontheedge.sql.model.SimpleNode)1