Skip to content

Special oracle tests #1279

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 9 commits into from
Aug 9, 2021
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.842
minimum = 0.840
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void setAlias(Alias alias) {

@Override
public Pivot getPivot() {
throw new UnsupportedOperationException("Not supported yet.");
return null;
}

@Override
Expand All @@ -64,7 +64,7 @@ public void setPivot(Pivot pivot) {

@Override
public UnPivot getUnPivot() {
throw new UnsupportedOperationException("Not supported yet.");
return null;
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public void visit(PlainSelect plainSelect) {
if (plainSelect.isUseBrackets()) {
buffer.append(")");
}

}

@Override
Expand Down Expand Up @@ -532,6 +533,21 @@ public void visit(TableFunction tableFunction) {
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
33 changes: 19 additions & 14 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1542,10 +1542,12 @@ String RelObjectNameWithoutValue() :
| tk=<K_ARRAY_LITERAL>
| tk=<K_STRING_FUNCTION_NAME>
| tk=<K_USER>
| tk=<K_RECYCLEBIN> | tk=<K_DBA_RECYCLEBIN>

/* Keywords for ALTER SESSION */
/* | tk=<K_NAME> */ | tk=<K_TIMEOUT> | tk=<K_PARALLEL>

| tk=<K_LINK>
/* Keywords for ALTER SYSTEM */
| tk=<K_LOG> | tk=<K_DUMP> | tk=<K_FLUSH> | tk=<K_ACTIVE> | tk=<K_RESUME> | tk=<K_SWITCH> | tk=<K_SUSPEND>
| tk=<K_ARCHIVE> | tk=<K_QUIESCE> | tk=<K_HISTORY> | tk=<K_SHUTDOWN> | tk=<K_REGISTER> | tk=<K_UNQIESCE>
Expand Down Expand Up @@ -1593,8 +1595,8 @@ String RelObjectNameExt():
{
( result=RelObjectName() | tk=<K_ALL> | tk=<K_ANY> | tk=<K_SOME> | tk=<K_LEFT> | tk=<K_RIGHT> | tk=<K_SET>
| tk=<K_DOUBLE> | tk=<K_IF> | tk=<K_IIF> | tk=<K_OPTIMIZE> | tk=<K_LIMIT>
| tk=<K_OFFSET> | tk=<K_PROCEDURE> | tk=<K_PUBLIC>
| tk=<K_CASEWHEN> | tk=<K_IN> )
| tk=<K_OFFSET> | tk=<K_PROCEDURE> | tk=<K_PUBLIC>
| tk=<K_CASEWHEN> | tk=<K_IN> | tk=<K_GROUPING> )
{
if (tk!=null) result=tk.image;
return result;
Expand All @@ -1609,7 +1611,7 @@ String RelObjectNameExt2():
String result=null;
}
{
( result=RelObjectNameExt() | tk=<K_FROM> | tk=<K_SELECT> | tk=<K_CURRENT>)
( result=RelObjectNameExt() | tk=<K_FROM> | tk=<K_SELECT> | tk=<K_CURRENT> )
{
if (tk!=null) result=tk.image;
return result;
Expand Down Expand Up @@ -2535,22 +2537,25 @@ GroupByElement GroupByColumnReferences():
( LOOKAHEAD(2) (
"(" ")" { groupBy.withUsingBrackets(true); }
)
|
LOOKAHEAD(2) (
<K_GROUPING> <K_SETS> "("
( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } )

( "," ( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } ) )*
")"
)
| LOOKAHEAD(3) (
"(" list = SimpleExpressionList(true) ")" { groupBy.setGroupByExpressionList(list); }
)
|
( list = SimpleExpressionList(false) { groupBy.setGroupByExpressionList(list); }
LOOKAHEAD(2) (
list = SimpleExpressionList(false) { groupBy.setGroupByExpressionList(list); }
)
|
<K_GROUPING> <K_SETS> "("
( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } )

( "," ( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } ) )*
")"
)
{
return groupBy;
Expand Down
Loading