Skip to content

Commit 8c1eba2

Browse files
Fixes #1385 and PR#1380 (#1386)
Add another Alias() Keyword related LOOKAHEAD Fix a Keyword Spelling Error in the Deparser Remove UNPIVOT from the PARENTHESIS Deparser, as it was an ugly workaround made obsolete by PR #1380
1 parent 2335ed1 commit 8c1eba2

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,12 @@ public void visit(UnPivot unpivot) {
307307
boolean showOptions = unpivot.getIncludeNullsSpecified();
308308
boolean includeNulls = unpivot.getIncludeNulls();
309309
List<Column> unpivotForClause = unpivot.getUnPivotForClause();
310-
buffer.append(" UNPIVOT").append(showOptions && includeNulls ? " INCLUDE NULLS" : "")
311-
.append(showOptions && !includeNulls ? " EXCULDE NULLS" : "").append(" (")
312-
.append(unpivot.getUnPivotClause()).append(" FOR ")
313-
.append(PlainSelect.getStringList(unpivotForClause, true,
310+
buffer
311+
.append(" UNPIVOT")
312+
.append(showOptions && includeNulls ? " INCLUDE NULLS" : "")
313+
.append(showOptions && !includeNulls ? " EXCLUDE NULLS" : "")
314+
.append(" (").append(unpivot.getUnPivotClause())
315+
.append(" FOR ").append(PlainSelect.getStringList(unpivotForClause, true,
314316
unpivotForClause != null && unpivotForClause.size() > 1))
315317
.append(" IN ").append(PlainSelect.getStringList(unpivot.getUnPivotInClause(), true, true)).append(")");
316318
if (unpivot.getAlias() != null) {
@@ -533,20 +535,6 @@ public void visit(ParenthesisFromItem parenthesis) {
533535
buffer.append("(");
534536
parenthesis.getFromItem().accept(this);
535537

536-
//@todo: investigate, why the Pivot is handled already
537-
// while the UnPivot is NOT handled.
538-
// Something here is wrong and the code below is just a work around
539-
540-
/* handled already somehow somewhere, see Special Oracle Test "pivot07_Parenthesis.sql"
541-
if (parenthesis.getFromItem().getPivot()!=null) {
542-
parenthesis.getFromItem().getPivot().accept(this);
543-
}
544-
*/
545-
546-
if (parenthesis.getFromItem().getUnPivot()!=null) {
547-
parenthesis.getFromItem().getUnPivot().accept(this);
548-
}
549-
550538
buffer.append(")");
551539
if (parenthesis.getAlias() != null) {
552540
buffer.append(parenthesis.getAlias().toString());

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ UnPivot UnPivot():
22852285
unpivotInClause = PivotSingleInItems()
22862286
")"
22872287
")"
2288-
[ alias = Alias() ]
2288+
[ LOOKAHEAD(2) alias = Alias() ]
22892289
{
22902290
retval.setUnPivotClause(unpivotClause);
22912291
retval.setUnPivotForClause(unpivotForClause);

0 commit comments

Comments
 (0)