Skip to content

Commit fbe97a8

Browse files
fix: try working around UnsupportedStatement issue
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 7daf7af commit fbe97a8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ Statement Statement() #Statement:
719719
( <ST_SEMICOLON> | <EOF> )
720720
)
721721
|
722-
LOOKAHEAD( { getAsBoolean(Feature.allowUnsupportedStatements) } ) stm = UnsupportedStatement()
722+
LOOKAHEAD( { stm==null && getAsBoolean(Feature.allowUnsupportedStatements) } ) stm = UnsupportedStatement()
723723
} catch (ParseException ex) {
724724
if ( getAsBoolean(Feature.allowUnsupportedStatements) ) {
725725
stm = new UnsupportedStatement( stm.toString(), error_skipto(ST_SEMICOLON) );

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,4 +5814,22 @@ public void testIssue1833() throws JSQLParserException {
58145814
String stmt = "SELECT age, name, gender FROM user_info INTO TEMP user_temp WITH NO LOG";
58155815
assertSqlCanBeParsedAndDeparsed(stmt);
58165816
}
5817+
5818+
@Test
5819+
void testGroupByWithHaving() throws JSQLParserException {
5820+
String sqlStr = "-- GROUP BY\n"
5821+
+ "SELECT a\n"
5822+
+ " , b\n"
5823+
+ " , c\n"
5824+
+ " , Sum( d )\n"
5825+
+ "FROM t\n"
5826+
+ "GROUP BY a\n"
5827+
+ " , b\n"
5828+
+ " , c\n"
5829+
+ "HAVING Sum( d ) > 0\n"
5830+
+ " AND Count( * ) > 1\n"
5831+
+ ";";
5832+
Statement stmt = assertSqlCanBeParsedAndDeparsed(sqlStr);
5833+
Assertions.assertInstanceOf(Select.class, stmt);
5834+
}
58175835
}

0 commit comments

Comments
 (0)