Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unsupported statement #1519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 11, 2022
Merged

Conversation

manticore-projects
Copy link
Contributor

@manticore-projects manticore-projects commented Apr 24, 2022

Implement Unsupported statement, which will return any unparsable statement or fragment as a list of tokens.

This Feature is OFF by default and can be activated on demand:

        String sqlStr = "this is an unsupported statement";

        assertSqlCanBeParsedAndDeparsed(sqlStr, true, parser -> parser.withUnsupportedStatements(true) );

        Assertions.assertThrowsExactly(JSQLParserException.class, new Executable() {
            @Override
            public void execute() throws Throwable {
                CCJSqlParserUtil.parse(sqlStr, parser -> parser.withUnsupportedStatements(false) );
            }
        });

However, there are 2 caveats:

  1. It does not work within BEGIN ... END blocks (because its hard to distinguish the END token from an Unsupported Statement
  2. It is always ACTIVE for the Statements() production since the needed LOOKAHEAD does not work, but results in a stack overflow (maybe a JavaCC bug)

Also IF ... ELSE ... has not been considered yet. I do not think, it is relevant.

Fixes #1510

Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
- Add Feature allowUnsupportedStatement, default=false
- Fully implement UnsupportedStatement for the Statement() production
- Partially implement UnsupportedStatement for the Statements() production, works only when UnsupportedStatement comes first
Disable STATEMENTS() test, which will never fail and add comments to this regard
Copy link
Member

@wumpz wumpz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I will merge. I find the idea of parsing without exceptions very attractive. :)

try {
(stm = SingleStatement() | stm = Block()) { list.add(stm); } <ST_SEMICOLON>
( (stm = SingleStatement() | stm = Block()) <ST_SEMICOLON> { list.add(stm); } )*
(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I find your version much harder to read.

@wumpz wumpz merged commit 59bb9a4 into JSQLParser:master May 11, 2022
@vkostyukov
Copy link

I like this. Any idea when this is going to be released?

@wumpz
Copy link
Member

wumpz commented May 11, 2022

At the moment I am deploying a new SNAPSHOT version. To be honest releasing this was not yet a plan, since version 4.4 was released recently.

@manticore-projects manticore-projects deleted the UnsupportedStatement branch May 12, 2022 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't parse START TRANSACTION
3 participants