Skip to content

Commit

Permalink
fix: ALTER ... shall captureRest() only to the next statement ter…
Browse files Browse the repository at this point in the history
…minator

- fixes #1993

Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
  • Loading branch information
manticore-projects committed Apr 18, 2024
1 parent c4e013b commit 15d14ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ xslt {
}

tasks.register('sphinx', Exec) {
dependsOn(gitChangelogTask, renderRR, xslt, updateKeywords, xmldoc)
dependsOn(gitChangelogTask, renderRR, xslt, xmldoc)

String PROLOG = """
.. |_| unicode:: U+00A0
Expand Down Expand Up @@ -504,7 +504,7 @@ tasks.register('sphinx', Exec) {
}

publish {
dependsOn(check, gitChangelogTask, renderRR, xslt, updateKeywords, xmldoc)
dependsOn(check, gitChangelogTask, renderRR, xslt, xmldoc)
}

publishing {
Expand Down Expand Up @@ -615,5 +615,5 @@ tasks.register('upload') {
}
}
}
upload.dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, updateKeywords, xmldoc)
upload.dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc)

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 @@ -7574,7 +7574,7 @@ List<String> captureRest() {
while(true) {
tok = getToken(1);
int l = tokens.size();
if( tok.kind == EOF ) {
if( tok.kind == EOF || tok.kind == ST_SEMICOLON ) {
break;
} else if ( l>0 && ( tok.image.equals(".") || tokens.get(l-1).endsWith(".")) ) {
tokens.set(l-1, tokens.get(l-1) + tok.image);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public void execute() throws Throwable {
});
}

@Test
public void testCaptureRestIssue1993() throws JSQLParserException {
String sqlStr = "Select 1; ALTER TABLE \"inter\".\"inter_user_rec\" \n"
+ " OWNER TO \"postgres\"; select 2; select 3;";
Statements statements = CCJSqlParserUtil.parseStatements(sqlStr,
parser -> parser.withErrorRecovery(false));
Assertions.assertEquals(4, statements.size());
}

@Test
void testAlter() throws JSQLParserException {
String sqlStr =
Expand Down

0 comments on commit 15d14ab

Please sign in to comment.