}
else if (right instanceof SqlNull && left instanceof SqlNull) {
replace(node, new SqlNull());
}
else if (left instanceof SqlNull && right instanceof SqlOr) {
SqlOr r = (SqlOr)right;
SqlExpr rleft = r.getLeftArg();
SqlExpr rright = r.getRightArg();
if (rleft instanceof SqlNull || rright instanceof SqlNull) {
replace(node, right.clone());
}
}
else if (right instanceof SqlNull && left instanceof SqlOr) {
SqlOr l = (SqlOr)left;
SqlExpr lleft = l.getLeftArg();
SqlExpr lright = l.getRightArg();
if (lleft instanceof SqlNull || lright instanceof SqlNull) {
replace(node, left.clone());
}
}
else if (right instanceof SqlNull && left instanceof SqlAnd) {
// value IS NOT NULL AND value = ? OR NULL
// -> value = ?
SqlAnd l = (SqlAnd)left;
SqlExpr lleft = l.getLeftArg();
SqlExpr lright = l.getRightArg();
SqlExpr isNotNull = arg(arg(lleft, SqlNot.class), SqlIsNull.class);
SqlExpr isNotEq = other(lright, isNotNull, SqlEq.class);
if (isNotEq instanceof SqlConstant) {
replace(node, lright);
}