Skip to content

Commit 6549bcb

Browse files
author
David Hayes
committed
Addressing PR Review comments. Using existing WITH and OFFSET keywords, adding ORDINALITY keyword.
1 parent bf1892e commit 6549bcb

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public class ParserKeywordsUtils {
109109
{"OPTIMIZE", RESTRICTED_ALIAS},
110110
{"OR", RESTRICTED_SQL2016},
111111
{"ORDER", RESTRICTED_SQL2016},
112+
{"ORDINALITY", RESTRICTED_SQL2016},
112113
{"OUTER", RESTRICTED_JSQLPARSER},
113114
{"OUTPUT", RESTRICTED_JSQLPARSER},
114115
{"OPTIMIZE ", RESTRICTED_JSQLPARSER},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public StringBuilder appendTo(StringBuilder builder) {
154154
builder.append(function.toString());
155155

156156
if (withClause != null) {
157-
builder.append(" ").append(withClause);
157+
builder.append(" WITH ").append(withClause);
158158
}
159159

160160
if (alias != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public <S> StringBuilder visit(TableFunction tableFunction, S context) {
748748
tableFunction.getFunction().accept(this.expressionVisitor, context);
749749

750750
if (tableFunction.getWithClause() != null) {
751-
builder.append(" ").append(tableFunction.getWithClause());
751+
builder.append(" WITH ").append(tableFunction.getWithClause());
752752
}
753753

754754
if (tableFunction.getAlias() != null) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
391391
| <K_OR:"OR">
392392
| <K_ORACLE_NAMED_PARAMETER_ASSIGNMENT: "=>">
393393
| <K_ORDER:"ORDER">
394+
| <K_ORDINALITY:"ORDINALITY">
394395
| <K_OUTER:"OUTER">
395396
| <K_OUTPUT:"OUTPUT">
396397
| <K_OVER:"OVER">
@@ -545,8 +546,6 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
545546
| <K_WHERE:"WHERE">
546547
| <K_WINDOW:"WINDOW">
547548
| <K_WITH:"WITH">
548-
| <K_WITH_OFFSET:"WITH OFFSET">
549-
| <K_WITH_ORDINALITY:"WITH ORDINALITY">
550549
| <K_WITH_TIES:"WITH TIES">
551550
| <K_WITHIN:"WITHIN">
552551
| <K_WITHOUT:"WITHOUT">
@@ -6643,7 +6642,7 @@ TableFunction TableFunction():
66436642
{
66446643
[ prefix = <K_LATERAL> ]
66456644
function=Function()
6646-
[ withClause = <K_WITH_OFFSET> | withClause = <K_WITH_ORDINALITY> ]
6645+
[ <K_WITH> ( withClause = <K_OFFSET> | withClause = <K_ORDINALITY> ) ]
66476646
{
66486647
return prefix!=null
66496648
? withClause!=null

src/test/java/net/sf/jsqlparser/statement/select/TableFunctionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ void testTableFunctionWithNamedParameterWhereNameIsOuterKeyword() throws JSQLPar
5252

5353
@ParameterizedTest
5454
@ValueSource(strings = {
55-
"WITH OFFSET",
56-
"WITH ORDINALITY"
55+
"OFFSET",
56+
"ORDINALITY"
5757
})
5858
void testTableFunctionWithSupportedWithClauses(String withClause) throws JSQLParserException {
59-
String sqlStr = "SELECT * FROM UNNEST(ARRAY[1, 2, 3]) " + withClause + " AS t(a, b)";
59+
String sqlStr = "SELECT * FROM UNNEST(ARRAY[1, 2, 3]) WITH " + withClause + " AS t(a, b)";
6060
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
6161
}
6262
}

0 commit comments

Comments
 (0)