if (!(leftExpr instanceof BooleanExpression))
{
throw new NucleusUserException("Query has clause " + leftExpr + " used with AND. This is illegal, and should be a boolean expression");
}
BooleanExpression right = (BooleanExpression)rightExpr;
BooleanExpression left = (BooleanExpression)leftExpr;
if (left.getSQLStatement() != null && right.getSQLStatement() != null &&
left.getSQLStatement() != right.getSQLStatement())
{
if (left.getSQLStatement() == stmt && right.getSQLStatement().isChildStatementOf(stmt))
{
// Apply right to its sub-statement now and return left
right.getSQLStatement().whereAnd(right, true);
stack.push(left);
return left;
}
else if (right.getSQLStatement() == stmt && left.getSQLStatement().isChildStatementOf(stmt))
{
// Apply left to its sub-statement now and return right
left.getSQLStatement().whereAnd(left, true);
stack.push(right);
return right;
}
// TODO Cater for more situations
}
if (compileComponent == CompilationComponent.FILTER)
{
// Make sure any simple boolean field clauses are suitable
left = getBooleanExpressionForUseInFilter(left);
right = getBooleanExpressionForUseInFilter(right);
}
left.encloseInParentheses();
right.encloseInParentheses();
BooleanExpression opExpr = left.ior(right);
stack.push(opExpr);
return opExpr;
}