Search in sources :

Example 11 with BinaryExpression

use of net.sf.jsqlparser.expression.BinaryExpression in project herddb by diennea.

the class SQLPlanner method findConstraintExpressionOnColumn.

private Expression findConstraintExpressionOnColumn(Expression where, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
    if (where instanceof AndExpression) {
        AndExpression and = (AndExpression) where;
        Expression keyOnLeft = findConstraintExpressionOnColumn(and.getLeftExpression(), columnName, tableAlias, expressionType);
        if (keyOnLeft != null) {
            return keyOnLeft;
        }
        Expression keyOnRight = findConstraintExpressionOnColumn(and.getRightExpression(), columnName, tableAlias, expressionType);
        if (keyOnRight != null) {
            return keyOnRight;
        }
    } else if (expressionType.isAssignableFrom(where.getClass())) {
        Expression keyDirect = validateColumnConstaintExpressionToExpression(where, columnName, tableAlias, expressionType);
        if (keyDirect != null) {
            return keyDirect;
        }
    }
    return null;
}
Also used : AndExpression(net.sf.jsqlparser.expression.operators.conditional.AndExpression) Expression(net.sf.jsqlparser.expression.Expression) AlterExpression(net.sf.jsqlparser.statement.alter.AlterExpression) BinaryExpression(net.sf.jsqlparser.expression.BinaryExpression) AndExpression(net.sf.jsqlparser.expression.operators.conditional.AndExpression) SignedExpression(net.sf.jsqlparser.expression.SignedExpression) CompiledSQLExpression(herddb.sql.expressions.CompiledSQLExpression)

Example 12 with BinaryExpression

use of net.sf.jsqlparser.expression.BinaryExpression in project herddb by diennea.

the class SQLPlanner method findConstraintOnColumn.

private static Expression findConstraintOnColumn(Expression where, String columnName, String tableAlias, Class<? extends BinaryExpression> expressionType) throws StatementExecutionException {
    if (where instanceof AndExpression) {
        AndExpression and = (AndExpression) where;
        Expression keyOnLeft = findConstraintOnColumn(and.getLeftExpression(), columnName, tableAlias, expressionType);
        if (keyOnLeft != null) {
            return keyOnLeft;
        }
        Expression keyOnRight = findConstraintOnColumn(and.getRightExpression(), columnName, tableAlias, expressionType);
        if (keyOnRight != null) {
            return keyOnRight;
        }
    } else if (expressionType.isAssignableFrom(where.getClass())) {
        Expression keyDirect = validateColumnConstaintToExpression(where, columnName, tableAlias, expressionType);
        if (keyDirect != null) {
            return keyDirect;
        }
    }
    return null;
}
Also used : AndExpression(net.sf.jsqlparser.expression.operators.conditional.AndExpression) Expression(net.sf.jsqlparser.expression.Expression) AlterExpression(net.sf.jsqlparser.statement.alter.AlterExpression) BinaryExpression(net.sf.jsqlparser.expression.BinaryExpression) AndExpression(net.sf.jsqlparser.expression.operators.conditional.AndExpression) SignedExpression(net.sf.jsqlparser.expression.SignedExpression) CompiledSQLExpression(herddb.sql.expressions.CompiledSQLExpression)

Aggregations

BinaryExpression (net.sf.jsqlparser.expression.BinaryExpression)12 Expression (net.sf.jsqlparser.expression.Expression)10 AndExpression (net.sf.jsqlparser.expression.operators.conditional.AndExpression)9 SignedExpression (net.sf.jsqlparser.expression.SignedExpression)7 CompiledSQLExpression (herddb.sql.expressions.CompiledSQLExpression)5 ArrayList (java.util.ArrayList)5 AlterExpression (net.sf.jsqlparser.statement.alter.AlterExpression)4 List (java.util.List)3 JdbcParameter (net.sf.jsqlparser.expression.JdbcParameter)3 Parenthesis (net.sf.jsqlparser.expression.Parenthesis)3 OrExpression (net.sf.jsqlparser.expression.operators.conditional.OrExpression)3 LikeExpression (net.sf.jsqlparser.expression.operators.relational.LikeExpression)3 Column (herddb.model.Column)2 StatementExecutionException (herddb.model.StatementExecutionException)2 RawString (herddb.utils.RawString)2 AbstractMap (java.util.AbstractMap)2 Map (java.util.Map)2 CaseExpression (net.sf.jsqlparser.expression.CaseExpression)2 DoubleValue (net.sf.jsqlparser.expression.DoubleValue)2 Function (net.sf.jsqlparser.expression.Function)2