File tree 2 files changed +22
-3
lines changed
main/jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/piped
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -2316,6 +2316,13 @@ Select Select() #Select:
2316
2316
}
2317
2317
{
2318
2318
(
2319
+
2320
+ //@todo: avoid this expensive semantic look ahead
2321
+ LOOKAHEAD( [ WithList() ] FromQuery()) (
2322
+ [ with=WithList() ]
2323
+ select = FromQuery()
2324
+ )
2325
+ |
2319
2326
(
2320
2327
[ with=WithList() ]
2321
2328
(
@@ -2335,8 +2342,6 @@ Select Select() #Select:
2335
2342
[ LOOKAHEAD(<K_FETCH>) fetch = Fetch() { select.setFetch(fetch);} ]
2336
2343
[ LOOKAHEAD(<K_WITH> <K_ISOLATION>) withIsolation = WithIsolation() { select.setIsolation(withIsolation);} ]
2337
2344
)
2338
- |
2339
- select = FromQuery()
2340
2345
)
2341
2346
{
2342
2347
linkAST(select, jjtThis);
@@ -3166,7 +3171,8 @@ List<WithItem<?>> WithList():
3166
3171
WithItem with = null;
3167
3172
}
3168
3173
{
3169
- <K_WITH> with=WithItem() { withItemsList.add(with); } ("," with=WithItem() { withItemsList.add(with); } )*
3174
+ <K_WITH> with=WithItem() { withItemsList.add(with); }
3175
+ ( LOOKAHEAD(3) "," with=WithItem() { withItemsList.add(with); } )*
3170
3176
3171
3177
{ return withItemsList; }
3172
3178
}
Original file line number Diff line number Diff line change @@ -231,4 +231,17 @@ void testParseAndDeparseIssue74() throws JSQLParserException {
231
231
// formatter:on
232
232
TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
233
233
}
234
+
235
+ @ Test
236
+ void testParseAndDeparseNestedWithIssue2168 () throws JSQLParserException {
237
+ // formatter:off
238
+ String sqlStr =
239
+ "with b as (\n " +
240
+ " with a as (select 1)\n " +
241
+ " from a )\n " +
242
+ "from b\n " +
243
+ ";" ;
244
+ // formatter:on
245
+ TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
246
+ }
234
247
}
You can’t perform that action at this time.
0 commit comments