Skip to content

Commit

Permalink
fix: ExpressionVisitor.visit(AllTableColumns) method isn't being call…
Browse files Browse the repository at this point in the history
…ed. (#1942)

This fixes a regression introduced in change #4b4ae04f44ff18b669d0f30d637e5b7c64b085e4: feat: BigQuery Except(..) Replace(..) syntax
  • Loading branch information
broneill authored Jan 6, 2024
1 parent 92e02c6 commit bc16618
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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());
}
}

0 comments on commit bc16618

Please sign in to comment.