Skip to content

Commit 346eea5

Browse files
Special oracle tests (#1279)
* Allow keywords: LINK, GROUPING() * Deparse ParenthesisFromItem's Pivot and UnPivot correctly * Write Test results to the SQL File Reduce the noise during the test Update/correct the list of expected passing files Get the benchmark from the list of expected passing files * There are no Pivots or UnPivots yet, so we will return NULL. * Record the expected Test Results on each SQL Source Fail the test when any expected success suddenly fails * Improve Test Coverage * Appease Codacy
1 parent b601407 commit 346eea5

File tree

277 files changed

+722
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+722
-56
lines changed

src/main/java/net/sf/jsqlparser/statement/select/ParenthesisFromItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void setAlias(Alias alias) {
5454

5555
@Override
5656
public Pivot getPivot() {
57-
throw new UnsupportedOperationException("Not supported yet.");
57+
return null;
5858
}
5959

6060
@Override
@@ -64,7 +64,7 @@ public void setPivot(Pivot pivot) {
6464

6565
@Override
6666
public UnPivot getUnPivot() {
67-
throw new UnsupportedOperationException("Not supported yet.");
67+
return null;
6868
}
6969

7070
@Override

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public void visit(PlainSelect plainSelect) {
224224
if (plainSelect.isUseBrackets()) {
225225
buffer.append(")");
226226
}
227+
227228
}
228229

229230
@Override
@@ -532,6 +533,21 @@ public void visit(TableFunction tableFunction) {
532533
public void visit(ParenthesisFromItem parenthesis) {
533534
buffer.append("(");
534535
parenthesis.getFromItem().accept(this);
536+
537+
//@todo: investigate, why the Pivot is handled already
538+
// while the UnPivot is NOT handled.
539+
// Something here is wrong and the code below is just a work around
540+
541+
/* handled already somehow somewhere, see Special Oracle Test "pivot07_Parenthesis.sql"
542+
if (parenthesis.getFromItem().getPivot()!=null) {
543+
parenthesis.getFromItem().getPivot().accept(this);
544+
}
545+
*/
546+
547+
if (parenthesis.getFromItem().getUnPivot()!=null) {
548+
parenthesis.getFromItem().getUnPivot().accept(this);
549+
}
550+
535551
buffer.append(")");
536552
if (parenthesis.getAlias() != null) {
537553
buffer.append(parenthesis.getAlias().toString());

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,10 +1609,12 @@ String RelObjectNameWithoutValue() :
16091609
| tk=<K_ARRAY_LITERAL>
16101610
| tk=<K_STRING_FUNCTION_NAME>
16111611
| tk=<K_USER>
1612+
| tk=<K_RECYCLEBIN> | tk=<K_DBA_RECYCLEBIN>
16121613

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

1617+
| tk=<K_LINK>
16161618
/* Keywords for ALTER SYSTEM */
16171619
| tk=<K_LOG> | tk=<K_DUMP> | tk=<K_FLUSH> | tk=<K_ACTIVE> | tk=<K_RESUME> | tk=<K_SWITCH> | tk=<K_SUSPEND>
16181620
| tk=<K_ARCHIVE> | tk=<K_QUIESCE> | tk=<K_HISTORY> | tk=<K_SHUTDOWN> | tk=<K_REGISTER> | tk=<K_UNQIESCE>
@@ -1660,8 +1662,8 @@ String RelObjectNameExt():
16601662
{
16611663
( result=RelObjectName() | tk=<K_ALL> | tk=<K_ANY> | tk=<K_SOME> | tk=<K_LEFT> | tk=<K_RIGHT> | tk=<K_SET>
16621664
| tk=<K_DOUBLE> | tk=<K_IF> | tk=<K_IIF> | tk=<K_OPTIMIZE> | tk=<K_LIMIT>
1663-
| tk=<K_OFFSET> | tk=<K_PROCEDURE> | tk=<K_PUBLIC>
1664-
| tk=<K_CASEWHEN> | tk=<K_IN> )
1665+
| tk=<K_OFFSET> | tk=<K_PROCEDURE> | tk=<K_PUBLIC>
1666+
| tk=<K_CASEWHEN> | tk=<K_IN> | tk=<K_GROUPING> )
16651667
{
16661668
if (tk!=null) result=tk.image;
16671669
return result;
@@ -1676,7 +1678,7 @@ String RelObjectNameExt2():
16761678
String result=null;
16771679
}
16781680
{
1679-
( result=RelObjectNameExt() | tk=<K_FROM> | tk=<K_SELECT> | tk=<K_CURRENT>)
1681+
( result=RelObjectNameExt() | tk=<K_FROM> | tk=<K_SELECT> | tk=<K_CURRENT> )
16801682
{
16811683
if (tk!=null) result=tk.image;
16821684
return result;
@@ -2602,22 +2604,25 @@ GroupByElement GroupByColumnReferences():
26022604
( LOOKAHEAD(2) (
26032605
"(" ")" { groupBy.withUsingBrackets(true); }
26042606
)
2607+
|
2608+
LOOKAHEAD(2) (
2609+
<K_GROUPING> <K_SETS> "("
2610+
( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
2611+
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
2612+
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } )
2613+
2614+
( "," ( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
2615+
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
2616+
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } ) )*
2617+
")"
2618+
)
26052619
| LOOKAHEAD(3) (
26062620
"(" list = SimpleExpressionList(true) ")" { groupBy.setGroupByExpressionList(list); }
26072621
)
26082622
|
2609-
( list = SimpleExpressionList(false) { groupBy.setGroupByExpressionList(list); }
2623+
LOOKAHEAD(2) (
2624+
list = SimpleExpressionList(false) { groupBy.setGroupByExpressionList(list); }
26102625
)
2611-
|
2612-
<K_GROUPING> <K_SETS> "("
2613-
( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
2614-
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
2615-
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } )
2616-
2617-
( "," ( LOOKAHEAD(2) "(" ")" { groupBy.addGroupingSet(new ExpressionList()); }
2618-
| LOOKAHEAD(3) "(" list = SimpleExpressionList(true) ")" { groupBy.addGroupingSet(list); }
2619-
| expr = SimpleExpression() { groupBy.addGroupingSet(expr); } ) )*
2620-
")"
26212626
)
26222627
{
26232628
return groupBy;

0 commit comments

Comments
 (0)