Skip to content
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
24 changes: 6 additions & 18 deletions src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,12 @@ public void visit(UnPivot unpivot) {
boolean showOptions = unpivot.getIncludeNullsSpecified();
boolean includeNulls = unpivot.getIncludeNulls();
List<Column> unpivotForClause = unpivot.getUnPivotForClause();
buffer.append(" UNPIVOT").append(showOptions && includeNulls ? " INCLUDE NULLS" : "")
.append(showOptions && !includeNulls ? " EXCULDE NULLS" : "").append(" (")
.append(unpivot.getUnPivotClause()).append(" FOR ")
.append(PlainSelect.getStringList(unpivotForClause, true,
buffer
.append(" UNPIVOT")
.append(showOptions && includeNulls ? " INCLUDE NULLS" : "")
.append(showOptions && !includeNulls ? " EXCLUDE NULLS" : "")
.append(" (").append(unpivot.getUnPivotClause())
.append(" FOR ").append(PlainSelect.getStringList(unpivotForClause, true,
unpivotForClause != null && unpivotForClause.size() > 1))
.append(" IN ").append(PlainSelect.getStringList(unpivot.getUnPivotInClause(), true, true)).append(")");
if (unpivot.getAlias() != null) {
Expand Down Expand Up @@ -533,20 +535,6 @@ public void visit(ParenthesisFromItem parenthesis) {
buffer.append("(");
parenthesis.getFromItem().accept(this);

//@todo: investigate, why the Pivot is handled already
// while the UnPivot is NOT handled.
// Something here is wrong and the code below is just a work around

/* handled already somehow somewhere, see Special Oracle Test "pivot07_Parenthesis.sql"
if (parenthesis.getFromItem().getPivot()!=null) {
parenthesis.getFromItem().getPivot().accept(this);
}
*/

if (parenthesis.getFromItem().getUnPivot()!=null) {
parenthesis.getFromItem().getUnPivot().accept(this);
}

buffer.append(")");
if (parenthesis.getAlias() != null) {
buffer.append(parenthesis.getAlias().toString());
Expand Down
2 changes: 1 addition & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ UnPivot UnPivot():
unpivotInClause = PivotSingleInItems()
")"
")"
[ alias = Alias() ]
[ LOOKAHEAD(2) alias = Alias() ]
{
retval.setUnPivotClause(unpivotClause);
retval.setUnPivotForClause(unpivotForClause);
Expand Down