Skip to content

Commit

Permalink
fix: try working around UnsupportedStatement issue
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
  • Loading branch information
manticore-projects committed May 8, 2024
1 parent 7daf7af commit fbe97a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ Statement Statement() #Statement:
( <ST_SEMICOLON> | <EOF> )
)
|
LOOKAHEAD( { getAsBoolean(Feature.allowUnsupportedStatements) } ) stm = UnsupportedStatement()
LOOKAHEAD( { stm==null && getAsBoolean(Feature.allowUnsupportedStatements) } ) stm = UnsupportedStatement()
} catch (ParseException ex) {
if ( getAsBoolean(Feature.allowUnsupportedStatements) ) {
stm = new UnsupportedStatement( stm.toString(), error_skipto(ST_SEMICOLON) );
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5814,4 +5814,22 @@ public void testIssue1833() throws JSQLParserException {
String stmt = "SELECT age, name, gender FROM user_info INTO TEMP user_temp WITH NO LOG";
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
void testGroupByWithHaving() throws JSQLParserException {
String sqlStr = "-- GROUP BY\n"
+ "SELECT a\n"
+ " , b\n"
+ " , c\n"
+ " , Sum( d )\n"
+ "FROM t\n"
+ "GROUP BY a\n"
+ " , b\n"
+ " , c\n"
+ "HAVING Sum( d ) > 0\n"
+ " AND Count( * ) > 1\n"
+ ";";
Statement stmt = assertSqlCanBeParsedAndDeparsed(sqlStr);
Assertions.assertInstanceOf(Select.class, stmt);
}
}

0 comments on commit fbe97a8

Please sign in to comment.