I'm trying to find the easiest way to remove an expression (for example, a condition) from a query parsed with JSQLParser.
Let's assume I have the following query (no real logic here):
select a,b,c from table where a > 1 and c > 4 and a = b
Assuming that, I would like to remove one of the conditions, say "a = b", what would be the best way?
I used the following code to track down the condition that has two columns in an "EqualTo" expression, but now that I have the expression object in hand, I'm not sure what's the best way to remove it from the where clause.
subselect.getWhere().accept(new ExpressionVisitorAdapter() {
@Override
public void visit(EqualsTo expr) {
if (expr.getLeftExpression() instanceof Column && expr.getRightExpression() instanceof Column &&
((Column)expr.getLeftExpression()).getTable() != ((Column)expr.getRightExpression()).getTable()) {
// Now what?
}
}
});