Skip to content

Fix: DESC and EXPLAIN #1933

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 3 commits into from
Dec 23, 2023
Merged

Conversation

jxnu-liguobin
Copy link
Contributor

close #1931, to support MySQL {EXPLAIN | DESCRIBE | DESC} tbl_name
it is necessary to use LOOKAHEAD(3), It made explain01.sql change. It seems to be expected?

@@ -53,7 +61,8 @@ public void testValidateBlock() throws JSQLParserException {
@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Next time please use a Parametrised Test for this. Loops in Tests are an Anti-Pattern because you won't know which one failed. You can lookup the KeywordTests for getting a template.

@@ -1056,29 +1056,43 @@ PurgeStatement PurgeStatement(): {

DescribeStatement Describe(): {
Table table;
DescribeStatement stmt = new DescribeStatement();
Copy link
Contributor

Choose a reason for hiding this comment

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

Next time, create the statement at the end only after all tokens have parsed and passed, like:

return new Statement().withX(token.image).withY(token.image);

Its not a hard requirement, but in general Objects should be initialized only when needed.

@manticore-projects manticore-projects merged commit 45f98f8 into JSQLParser:master Dec 23, 2023
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.

[FEATURE] cannot parse DESC table_name
2 participants