Skip to content

fix: ExpressionVisitor.visit(AllTableColumns) method isn't being called. #1942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package net.sf.jsqlparser.statement.select;

import net.sf.jsqlparser.expression.ExpressionVisitor;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
Expand Down Expand Up @@ -50,4 +51,9 @@ public AllTableColumns withTable(Table table) {
public StringBuilder appendTo(StringBuilder builder) {
return super.appendTo(table.appendTo(builder).append("."));
}

@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.sf.jsqlparser.expression.operators.relational.InExpression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.select.AllTableColumns;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.statement.select.SelectVisitorAdapter;
Expand Down Expand Up @@ -241,4 +242,21 @@ public void testRowConstructor() throws JSQLParserException {
"CAST(ROW(dataid, value, calcMark) AS ROW(datapointid CHAR, value CHAR, calcMark CHAR))")
.accept(adapter);
}

@Test
public void testAllTableColumns() throws JSQLParserException {
PlainSelect plainSelect = (PlainSelect) CCJSqlParserUtil.parse("select a.* from foo a");
final AllTableColumns[] holder = new AllTableColumns[1];
Expression from = plainSelect.getSelectItems().get(0).getExpression();
from.accept(new ExpressionVisitorAdapter() {

@Override
public void visit(AllTableColumns all) {
holder[0] = all;
}
});

assertNotNull(holder[0]);
assertEquals("a.*", holder[0].toString());
}
}