diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java index 667331481..32a6dab0b 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItem.java @@ -47,5 +47,26 @@ default FromItem withUnPivot(UnPivot unpivot) { return this; } + default StringBuilder appendTo(StringBuilder builder, Alias alias) { + return appendTo(builder, alias, null, null); + } + + default StringBuilder appendTo(StringBuilder builder, Alias alias, Pivot pivot, + UnPivot unPivot) { + if (alias != null) { + builder.append(alias); + } + + if (pivot != null) { + builder.append(" ").append(pivot); + } + + if (unPivot != null) { + builder.append(" ").append(unPivot); + } + + return builder; + } + } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java index 13b78201c..d98614843 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java @@ -48,4 +48,22 @@ default void visit(ParenthesedFromItem parenthesedFromItem) { default void visit(Values values) { this.visit(values, null); } + + T visit(PlainSelect plainSelect, S context); + + default void visit(PlainSelect plainSelect) { + this.visit(plainSelect, null); + } + + T visit(SetOperationList setOperationList, S context); + + default void visit(SetOperationList setOperationList) { + this.visit(setOperationList, null); + } + + T visit(TableStatement tableStatement, S context); + + default void visit(TableStatement tableStatement) { + this.visit(tableStatement, null); + } } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java index 7daad1cab..fa530e32f 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitorAdapter.java @@ -49,4 +49,22 @@ public T visit(Values values, S context) { return null; } + + @Override + public T visit(PlainSelect plainSelect, S context) { + + return null; + } + + @Override + public T visit(SetOperationList setOperationList, S context) { + + return null; + } + + @Override + public T visit(TableStatement tableStatement, S context) { + + return null; + } } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/ParenthesedSelect.java b/src/main/java/net/sf/jsqlparser/statement/select/ParenthesedSelect.java index a33abf3a3..2e09a429f 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/ParenthesedSelect.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/ParenthesedSelect.java @@ -160,15 +160,7 @@ public T accept(StatementVisitor statementVisitor, S context) { public StringBuilder appendSelectBodyTo(StringBuilder builder) { builder.append("(").append(select).append(")"); - if (alias != null) { - builder.append(alias); - } - if (pivot != null) { - builder.append(" ").append(pivot); - } - if (unPivot != null) { - builder.append(" ").append(unPivot); - } + appendTo(builder, alias, pivot, unPivot); return builder; } } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java b/src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java index eb106869c..414a60945 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java @@ -317,6 +317,11 @@ public T accept(SelectVisitor selectVisitor, S context) { return selectVisitor.visit(this, context); } + @Override + public T accept(FromItemVisitor fromItemVisitor, S context) { + return fromItemVisitor.visit(this, context); + } + public OptimizeFor getOptimizeFor() { return optimizeFor; } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Select.java b/src/main/java/net/sf/jsqlparser/statement/select/Select.java index b0c8e9972..329bd6388 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/Select.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/Select.java @@ -9,6 +9,7 @@ */ package net.sf.jsqlparser.statement.select; +import net.sf.jsqlparser.expression.Alias; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; import net.sf.jsqlparser.parser.ASTNodeAccessImpl; @@ -23,7 +24,7 @@ import java.util.List; import java.util.Optional; -public abstract class Select extends ASTNodeAccessImpl implements Statement, Expression { +public abstract class Select extends ASTNodeAccessImpl implements Statement, Expression, FromItem { protected Table forUpdateTable = null; List> withItemsList; Limit limitBy; @@ -40,6 +41,9 @@ public abstract class Select extends ASTNodeAccessImpl implements Statement, Exp private boolean skipLocked; private Wait wait; private boolean noWait = false; + Alias alias; + Pivot pivot; + UnPivot unPivot; public static String orderByToString(List orderByElements) { return orderByToString(false, orderByElements); @@ -322,6 +326,39 @@ public void setSkipLocked(boolean skipLocked) { this.skipLocked = skipLocked; } + @Override + public Alias getAlias() { + return alias; + } + + @Override + public void setAlias(Alias alias) { + this.alias = alias; + } + + public Select withAlias(Alias alias) { + this.setAlias(alias); + return this; + } + + @Override + public Pivot getPivot() { + return pivot; + } + + @Override + public void setPivot(Pivot pivot) { + this.pivot = pivot; + } + + public UnPivot getUnPivot() { + return unPivot; + } + + public void setUnPivot(UnPivot unPivot) { + this.unPivot = unPivot; + } + public abstract StringBuilder appendSelectBodyTo(StringBuilder builder); @SuppressWarnings({"PMD.CyclomaticComplexity"}) @@ -381,6 +418,8 @@ public StringBuilder appendTo(StringBuilder builder) { } } + appendTo(builder, alias, pivot, unPivot); + return builder; } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/SetOperationList.java b/src/main/java/net/sf/jsqlparser/statement/select/SetOperationList.java index 46708e8c6..960c11e54 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/SetOperationList.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/SetOperationList.java @@ -27,6 +27,11 @@ public T accept(SelectVisitor selectVisitor, S context) { return selectVisitor.visit(this, context); } + @Override + public T accept(FromItemVisitor fromItemVisitor, S context) { + return fromItemVisitor.visit(this, context); + } + public List getOrderByElements() { return orderByElements; } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/TableStatement.java b/src/main/java/net/sf/jsqlparser/statement/select/TableStatement.java index 0b1e081c9..f1ccd0728 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/TableStatement.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/TableStatement.java @@ -55,4 +55,9 @@ public StringBuilder appendTo(StringBuilder builder) { public T accept(SelectVisitor selectVisitor, S context) { return selectVisitor.visit(this, context); } + + @Override + public T accept(FromItemVisitor fromItemVisitor, S context) { + return fromItemVisitor.visit(this, context); + } } diff --git a/src/main/java/net/sf/jsqlparser/statement/select/Values.java b/src/main/java/net/sf/jsqlparser/statement/select/Values.java index 627cbb4cb..e574b1a05 100644 --- a/src/main/java/net/sf/jsqlparser/statement/select/Values.java +++ b/src/main/java/net/sf/jsqlparser/statement/select/Values.java @@ -48,9 +48,7 @@ public void setExpressions(ExpressionList expressions) { public StringBuilder appendSelectBodyTo(StringBuilder builder) { builder.append("VALUES "); builder.append(expressions.toString()); - if (alias != null) { - builder.append(" ").append(alias); - } + appendTo(builder, alias); return builder; } diff --git a/src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java b/src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java index c56f396d4..81a265d8b 100644 --- a/src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java +++ b/src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java @@ -103,7 +103,7 @@ public StringBuilder visit(ParenthesedSelect select, S context) { } buffer.append("("); - select.getSelect().accept(this, context); + select.getSelect().accept((SelectVisitor) this, context); buffer.append(")"); if (select.getOrderByElements() != null) { @@ -330,6 +330,20 @@ public StringBuilder visit(PlainSelect plainSelect, S context) { if (plainSelect.isUseWithNoLog()) { buffer.append(" WITH NO LOG"); } + + Alias alias = plainSelect.getAlias(); + if (alias != null) { + buffer.append(alias); + } + Pivot pivot = plainSelect.getPivot(); + if (pivot != null) { + pivot.accept(this, context); + } + UnPivot unpivot = plainSelect.getUnPivot(); + if (unpivot != null) { + unpivot.accept(this, context); + } + return buffer; } @@ -618,7 +632,7 @@ public StringBuilder visit(SetOperationList list, S context) { if (i != 0) { buffer.append(' ').append(list.getOperations().get(i - 1)).append(' '); } - list.getSelects().get(i).accept(this, context); + list.getSelects().get(i).accept((SelectVisitor) this, context); } if (list.getOrderByElements() != null) { new OrderByDeParser(expressionVisitor, buffer).deParse(list.getOrderByElements()); @@ -636,6 +650,20 @@ public StringBuilder visit(SetOperationList list, S context) { if (list.getIsolation() != null) { buffer.append(list.getIsolation().toString()); } + + Alias alias = list.getAlias(); + if (alias != null) { + buffer.append(alias); + } + Pivot pivot = list.getPivot(); + if (pivot != null) { + pivot.accept(this, context); + } + UnPivot unpivot = list.getUnPivot(); + if (unpivot != null) { + unpivot.accept(this, context); + } + return buffer; } @@ -779,7 +807,7 @@ private void deparseOptimizeFor(OptimizeFor optimizeFor) { @Override void deParse(PlainSelect statement) { - statement.accept(this, null); + statement.accept((SelectVisitor) this, null); } } diff --git a/src/main/java/net/sf/jsqlparser/util/deparser/StatementDeParser.java b/src/main/java/net/sf/jsqlparser/util/deparser/StatementDeParser.java index ccc1099c3..cd16843fc 100644 --- a/src/main/java/net/sf/jsqlparser/util/deparser/StatementDeParser.java +++ b/src/main/java/net/sf/jsqlparser/util/deparser/StatementDeParser.java @@ -214,7 +214,7 @@ private StringBuilder addWithItemsToBuffer(List> withItemsList, @Override public StringBuilder visit(Select select, S context) { - select.accept(selectDeParser, context); + select.accept((SelectVisitor) selectDeParser, context); return buffer; } diff --git a/src/main/java/net/sf/jsqlparser/util/deparser/TableStatementDeParser.java b/src/main/java/net/sf/jsqlparser/util/deparser/TableStatementDeParser.java index e187faaab..47b271e34 100644 --- a/src/main/java/net/sf/jsqlparser/util/deparser/TableStatementDeParser.java +++ b/src/main/java/net/sf/jsqlparser/util/deparser/TableStatementDeParser.java @@ -10,15 +10,7 @@ package net.sf.jsqlparser.util.deparser; import net.sf.jsqlparser.expression.ExpressionVisitor; -import net.sf.jsqlparser.statement.select.LateralSubSelect; -import net.sf.jsqlparser.statement.select.Offset; -import net.sf.jsqlparser.statement.select.ParenthesedSelect; -import net.sf.jsqlparser.statement.select.PlainSelect; -import net.sf.jsqlparser.statement.select.SelectVisitor; -import net.sf.jsqlparser.statement.select.SetOperationList; -import net.sf.jsqlparser.statement.select.TableStatement; -import net.sf.jsqlparser.statement.select.Values; -import net.sf.jsqlparser.statement.select.WithItem; +import net.sf.jsqlparser.statement.select.*; /** * @author jxnu-liguobin @@ -101,6 +93,10 @@ public StringBuilder visit(TableStatement tableStatement, S context) { } // TODO UNION + + tableStatement.appendTo(buffer, tableStatement.getAlias(), tableStatement.getPivot(), + tableStatement.getUnPivot()); + return buffer; } } diff --git a/src/main/java/net/sf/jsqlparser/util/deparser/UpsertDeParser.java b/src/main/java/net/sf/jsqlparser/util/deparser/UpsertDeParser.java index 719c12a80..1038d145a 100644 --- a/src/main/java/net/sf/jsqlparser/util/deparser/UpsertDeParser.java +++ b/src/main/java/net/sf/jsqlparser/util/deparser/UpsertDeParser.java @@ -75,7 +75,7 @@ public void deParse(Upsert upsert) { if (upsert.getSelect() != null) { buffer.append(" "); - upsert.getSelect().accept(selectVisitor, null); + upsert.getSelect().accept((SelectVisitor) selectVisitor, null); } if (upsert.getDuplicateUpdateSets() != null) { diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/AlterViewValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/AlterViewValidator.java index db390af83..fd875b181 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/AlterViewValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/AlterViewValidator.java @@ -11,6 +11,7 @@ import net.sf.jsqlparser.parser.feature.Feature; import net.sf.jsqlparser.statement.create.view.AlterView; +import net.sf.jsqlparser.statement.select.SelectVisitor; import net.sf.jsqlparser.util.validation.ValidationCapability; import net.sf.jsqlparser.util.validation.metadata.NamedObject; @@ -27,7 +28,8 @@ public void validate(AlterView alterView) { validateName(c, NamedObject.view, alterView.getView().getFullyQualifiedName()); validateOptionalColumnNames(c, alterView.getColumnNames()); } - alterView.getSelect().accept(getValidator(SelectValidator.class), null); + alterView.getSelect().accept((SelectVisitor) getValidator(SelectValidator.class), + null); } } diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/CreateViewValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/CreateViewValidator.java index 262bb4e90..12c406f2c 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/CreateViewValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/CreateViewValidator.java @@ -14,6 +14,7 @@ import net.sf.jsqlparser.statement.create.view.ForceOption; import net.sf.jsqlparser.statement.create.view.TemporaryOption; import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectVisitor; import net.sf.jsqlparser.util.validation.ValidationCapability; import net.sf.jsqlparser.util.validation.metadata.NamedObject; @@ -38,7 +39,7 @@ public void validate(CreateView createView) { } SelectValidator v = getValidator(SelectValidator.class); Select select = createView.getSelect(); - select.accept(v, null); + select.accept((SelectVisitor) v, null); } } diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/SelectValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/SelectValidator.java index a908adebd..1948a78d7 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/SelectValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/SelectValidator.java @@ -139,6 +139,8 @@ public Void visit(PlainSelect plainSelect, S context) { validateFetch(plainSelect.getFetch()); } + validateOptional(plainSelect.getPivot(), p -> p.accept(this, context)); + return null; } @@ -155,7 +157,7 @@ public Void visit(ParenthesedSelect selectBody, S context) { selectBody.getWithItemsList() .forEach(withItem -> withItem.accept((SelectVisitor) this, context)); } - selectBody.getSelect().accept(this, context); + selectBody.getSelect().accept((SelectVisitor) this, context); validateOptional(selectBody.getPivot(), p -> p.accept(this, context)); return null; } @@ -204,7 +206,7 @@ public Void visit(PivotXml pivot, S context) { pivot.getFunctionItems().forEach(f -> f.getExpression().accept(v, context)); } if (pivot.getInSelect() != null) { - pivot.getInSelect().accept(this, context); + pivot.getInSelect().accept((SelectVisitor) this, context); } return null; } @@ -283,7 +285,7 @@ public Void visit(SetOperationList setOperation, S context) { } if (isNotEmpty(setOperation.getSelects())) { - setOperation.getSelects().forEach(s -> s.accept(this, context)); + setOperation.getSelects().forEach(s -> s.accept((SelectVisitor) this, context)); } validateOptionalOrderByElements(setOperation.getOrderByElements()); @@ -325,7 +327,8 @@ public Void visit(LateralSubSelect lateralSubSelect, S context) { validateFeature(Feature.lateralSubSelect); validateOptional(lateralSubSelect.getPivot(), p -> p.accept(this, context)); validateOptional(lateralSubSelect.getUnPivot(), up -> up.accept(this, context)); - validateOptional(lateralSubSelect.getSelect(), e -> e.accept(this, context)); + validateOptional(lateralSubSelect.getSelect(), + e -> e.accept((SelectVisitor) this, context)); return null; } diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/StatementValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/StatementValidator.java index 3c84aa60e..0e7f25a2e 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/StatementValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/StatementValidator.java @@ -55,6 +55,7 @@ import net.sf.jsqlparser.statement.merge.Merge; import net.sf.jsqlparser.statement.refresh.RefreshMaterializedViewStatement; import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectVisitor; import net.sf.jsqlparser.statement.show.ShowIndexStatement; import net.sf.jsqlparser.statement.show.ShowTablesStatement; import net.sf.jsqlparser.statement.truncate.Truncate; @@ -133,7 +134,7 @@ public Void visit(Select select, S context) { validateFeature(Feature.select); SelectValidator selectValidator = getValidator(SelectValidator.class); - select.accept(selectValidator, null); + select.accept((SelectVisitor) selectValidator, null); return null; } diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/UpdateValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/UpdateValidator.java index aabfaf3fa..058b6aa9f 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/UpdateValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/UpdateValidator.java @@ -10,6 +10,7 @@ package net.sf.jsqlparser.util.validation.validator; import net.sf.jsqlparser.parser.feature.Feature; +import net.sf.jsqlparser.statement.select.SelectVisitor; import net.sf.jsqlparser.statement.update.Update; import net.sf.jsqlparser.util.validation.ValidationCapability; @@ -40,7 +41,7 @@ public void validate(Update update) { if (update.isUseSelect()) { validateOptionalExpressions(update.getColumns()); validateOptional(update.getSelect(), - e -> e.accept(getValidator(SelectValidator.class), null)); + e -> e.accept((SelectVisitor) getValidator(SelectValidator.class), null)); } else { validateOptionalExpressions(update.getColumns()); validateOptionalExpressions(update.getExpressions()); diff --git a/src/main/java/net/sf/jsqlparser/util/validation/validator/UpsertValidator.java b/src/main/java/net/sf/jsqlparser/util/validation/validator/UpsertValidator.java index 0d0fb9b1d..585cf7132 100644 --- a/src/main/java/net/sf/jsqlparser/util/validation/validator/UpsertValidator.java +++ b/src/main/java/net/sf/jsqlparser/util/validation/validator/UpsertValidator.java @@ -11,6 +11,7 @@ import net.sf.jsqlparser.parser.feature.Feature; import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectVisitor; import net.sf.jsqlparser.statement.update.UpdateSet; import net.sf.jsqlparser.statement.upsert.Upsert; import net.sf.jsqlparser.util.validation.ValidationCapability; @@ -35,7 +36,7 @@ public void validate(Upsert upsert) { private void validateOptionalSelect(Select select) { if (select != null) { SelectValidator v = getValidator(SelectValidator.class); - select.accept(v, null); + select.accept((SelectVisitor) v, null); } } diff --git a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt index b980cdf24..7dd9706bd 100644 --- a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt +++ b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt @@ -3052,7 +3052,7 @@ FromItem FromItem() #FromItem: } { ( - LOOKAHEAD(3) fromItem = Values() + LOOKAHEAD(3, { !getAsBoolean(Feature.allowUnparenthesizedSubSelects) }) fromItem = Values() | LOOKAHEAD( TableFunction() ) fromItem=TableFunction() | @@ -3060,13 +3060,15 @@ FromItem FromItem() #FromItem: | LOOKAHEAD( ParenthesedFromItem() ) fromItem = ParenthesedFromItem() | - LOOKAHEAD(3) ( + LOOKAHEAD(3, { !getAsBoolean(Feature.allowUnparenthesizedSubSelects) }) ( fromItem=ParenthesedSelect() [ LOOKAHEAD(2) pivot=Pivot() { fromItem.setPivot(pivot); } ] [ LOOKAHEAD(2) unpivot=UnPivot() { fromItem.setUnPivot(unpivot); } ] ) | fromItem=LateralSubSelect() + | + LOOKAHEAD({ getAsBoolean(Feature.allowUnparenthesizedSubSelects) }) fromItem=Select() ) [ LOOKAHEAD(2) alias=Alias() { fromItem.setAlias(alias); } ] diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java index 1f0c3b931..ca8039843 100644 --- a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java +++ b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java @@ -5963,7 +5963,11 @@ void testGroupByWithHaving() throws JSQLParserException { @ValueSource(strings = { "SELECT SELECT 1", "SELECT 1 WHERE 1 = SELECT 1", - "SELECT 1 WHERE 1 IN SELECT 1" + "SELECT 1 WHERE 1 IN SELECT 1", + "SELECT * FROM SELECT 1", + "SELECT * FROM SELECT SELECT 1", + "SELECT * FROM SELECT 1 WHERE 1 = SELECT 1", + "SELECT * FROM SELECT 1 WHERE 1 IN SELECT 1" }) public void testUnparenthesizedSubSelect(String sqlStr) throws JSQLParserException { TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true, diff --git a/src/test/java/net/sf/jsqlparser/util/deparser/StatementDeParserTest.java b/src/test/java/net/sf/jsqlparser/util/deparser/StatementDeParserTest.java index 35e8db743..ce2733ff1 100644 --- a/src/test/java/net/sf/jsqlparser/util/deparser/StatementDeParserTest.java +++ b/src/test/java/net/sf/jsqlparser/util/deparser/StatementDeParserTest.java @@ -127,7 +127,7 @@ public void shouldUseProvidedDeparsersWhenDeParsingInsert() { then(withItem1).should().accept((SelectVisitor) selectDeParser, null); then(withItem2).should().accept((SelectVisitor) selectDeParser, null); - then(select).should().accept(selectDeParser, null); + then(select).should().accept((SelectVisitor) selectDeParser, null); then(duplicateUpdateExpression1).should().accept(expressionDeParser, null); then(duplicateUpdateExpression1).should().accept(expressionDeParser, null); } @@ -151,7 +151,7 @@ public void shouldUseProvidedDeParsersWhenDeParsingSelect() { // then(withItem1).should().accept((SelectVisitor) selectDeParser); // then(withItem2).should().accept((SelectVisitor) selectDeParser); - then(plainSelect).should().accept(selectDeParser, null); + then(plainSelect).should().accept((SelectVisitor) selectDeParser, null); } @Test @@ -309,7 +309,7 @@ public void shouldUseProvidedDeparsersWhenDeParsingUpsertWithExpressionList() { statementDeParser.visit(upsert); - then(select).should().accept(selectDeParser, null); + then(select).should().accept((SelectVisitor) selectDeParser, null); then(duplicateUpdateExpression1).should().accept(expressionDeParser, null); then(duplicateUpdateExpression1).should().accept(expressionDeParser, null); } @@ -327,7 +327,7 @@ public void shouldUseProvidedDeparsersWhenDeParsingIfThenStatement() public void testIssue1500AllColumns() throws JSQLParserException { String sqlStr = "select count(*) from some_table"; PlainSelect selectBody = (PlainSelect) CCJSqlParserUtil.parse(sqlStr); - selectBody.accept(new SelectDeParser(), null); + selectBody.accept((SelectVisitor) new SelectDeParser(), null); } @Test @@ -341,7 +341,7 @@ public void testIssue1836() throws JSQLParserException { public void testIssue1500AllTableColumns() throws JSQLParserException { String sqlStr = "select count(a.*) from some_table a"; PlainSelect selectBody = (PlainSelect) CCJSqlParserUtil.parse(sqlStr); - selectBody.accept(new SelectDeParser(), null); + selectBody.accept((SelectVisitor) new SelectDeParser(), null); } @Test