}
}
else if (arg instanceof SqlAnd) {
// value IS NOT NULL AND value = ? OR NULL
// -> value = ?
SqlAnd and = (SqlAnd)arg;
// search for the value IS NOT NULL expression
for (SqlExpr isNotNull : and.getArgs()) {
SqlExpr variable = arg(arg(isNotNull, SqlNot.class), SqlIsNull.class);
if (variable == null) {
continue;
}
// search for the value = ? expression
for (SqlExpr eq : and.getArgs()) {
SqlExpr constant = other(eq, variable, SqlEq.class);
if (constant == null) {
continue;
}
if (constant instanceof SqlConstant) {
node.removeChildNode(sqlNull);
and.removeChildNode(isNotNull);
if (node.getNumberOfArguments() == 1) {
replace(node, node.getArg(0));
}
if (and.getNumberOfArguments() == 1) {
replace(and, and.getArg(0));
}
return;
}
}
}