You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a query: select A from B where (A ~ 'fish') which when tree walking with an ExpressionVisitor, I end up in void visit(RegExpMatchOperator regExpMatchOperator) {...}, the parent of the regExpMatchOperator is the PlainSelect, and not the ParenthesedExpressionList
Test Case (which fails on the final assertion):
importnet.sf.jsqlparser.JSQLParserException;
importnet.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList;
importnet.sf.jsqlparser.expression.operators.relational.RegExpMatchOperator;
importnet.sf.jsqlparser.parser.CCJSqlParserUtil;
importnet.sf.jsqlparser.statement.select.PlainSelect;
importorg.junit.jupiter.api.Test;
importstaticorg.assertj.core.api.Assertions.assertThat;
publicclassRegexpMatchesTest {
@TestvoidparentIsExpected() throwsJSQLParserException {
varparsed = CCJSqlParserUtil.parse("select A from B where (A ~ 'fish')");
assertThat(parsed).isInstanceOf(PlainSelect.class);
varselect = (PlainSelect) parsed;
assertThat(select.getWhere()).isInstanceOf(ParenthesedExpressionList.class);
varparenthesis = (ParenthesedExpressionList<?>) select.getWhere();
assertThat(parenthesis.getFirst()).isInstanceOf(RegExpMatchOperator.class);
varregExpMatchOperator = (RegExpMatchOperator) parenthesis.getFirst();
assertThat(regExpMatchOperator.getParent()).isSameAs(parenthesis);
}
}
My expectation is that the parent node of the regex operator should be the parenthesis object, not the plain select
The text was updated successfully, but these errors were encountered:
Although I note now, that ParenthesedExpressionList does not contain a getParent() method, so you couldn't tree walk up to the PlainSelect from the ParenthesedExpressionList. I guess that because getParent() is a member of ASTNodeAccessImpl, and you can't have ExpressionList extend ArrayList and ASTNodeAccessImpl.
An extension of this problem, which I think is more problematic: SELECT A FROM B WHERE (A ~ 'fish' AND A !~ 'banana')
The RegExpMatchOperator of A ~ 'fish' has a parent of the PlainSelect and not AndExpression (as does the A !~ 'banana'), even though the structure is PlainSelect.where => ParenthesedExpressionList(AndExpression(RegExpMatchOperator, RegExpMatchOperator))
where AndExpression does extend ASTNodeAccessImpl
I have a query:
select A from B where (A ~ 'fish')
which when tree walking with an ExpressionVisitor, I end up invoid visit(RegExpMatchOperator regExpMatchOperator) {...}
, the parent of theregExpMatchOperator
is thePlainSelect
, and not theParenthesedExpressionList
Test Case (which fails on the final assertion):
My expectation is that the parent node of the regex operator should be the parenthesis object, not the plain select
The text was updated successfully, but these errors were encountered: