File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
main/jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/piped Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -2316,6 +2316,13 @@ Select Select() #Select:
23162316}
23172317{
23182318 (
2319+
2320+ //@todo: avoid this expensive semantic look ahead
2321+ LOOKAHEAD( [ WithList() ] FromQuery()) (
2322+ [ with=WithList() ]
2323+ select = FromQuery()
2324+ )
2325+ |
23192326 (
23202327 [ with=WithList() ]
23212328 (
@@ -2335,8 +2342,6 @@ Select Select() #Select:
23352342 [ LOOKAHEAD(<K_FETCH>) fetch = Fetch() { select.setFetch(fetch);} ]
23362343 [ LOOKAHEAD(<K_WITH> <K_ISOLATION>) withIsolation = WithIsolation() { select.setIsolation(withIsolation);} ]
23372344 )
2338- |
2339- select = FromQuery()
23402345 )
23412346 {
23422347 linkAST(select, jjtThis);
@@ -3166,7 +3171,8 @@ List<WithItem<?>> WithList():
31663171 WithItem with = null;
31673172}
31683173{
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); } )*
31703176
31713177 { return withItemsList; }
31723178}
Original file line number Diff line number Diff line change @@ -231,4 +231,17 @@ void testParseAndDeparseIssue74() throws JSQLParserException {
231231 // formatter:on
232232 TestUtils .assertSqlCanBeParsedAndDeparsed (sqlStr , true );
233233 }
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+ }
234247}
You can’t perform that action at this time.
0 commit comments