Skip to content
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

problem "WITH" on INSERT #353

Closed
ivanavguston-oviva opened this issue Sep 10, 2021 · 5 comments
Closed

problem "WITH" on INSERT #353

ivanavguston-oviva opened this issue Sep 10, 2021 · 5 comments
Assignees
Milestone

Comments

@ivanavguston-oviva
Copy link

it legitimate construction but linter does not allow it

 Line 2, col 1 at "WITH": Unexpected keyword.
 Line 2, col 1 at "WITH": Unrecognized statement type.

INSERT ... WITH ... SELECT ... https://dev.mysql.com/doc/refman/8.0/en/with.html

@williamdes williamdes added this to the 4.7.3 milestone Sep 10, 2021
@williamdes
Copy link
Member

Thanks for reporting this !

@ivanavguston-oviva
Copy link
Author

Hello folks, do you have any update for me?

@williamdes
Copy link
Member

Hello folks, do you have any update for me?

Hi !
Actually we recently added the WITH keyword, see #165 and #331

Could you test the dev-master version of the library in case it already improved this ?

Hi @iifawzi
Would you mind having a look if this is now covered ?

@iifawzi
Copy link
Contributor

iifawzi commented Dec 4, 2021

Hi, I can confirm that it's not covered. Also such form of statements are not covered too.

CREATE TABLE ... WITH ... SELECT ...
CREATE VIEW ... WITH ... SELECT ...
REPLACE ... WITH ... SELECT ...

Examples:

INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte
INSERT INTO table_name WITH cte (col1) AS ( SELECT 1 ) SELECT col1 FROM cte ON DUPLICATE KEY UPDATE col_name = 3
CREATE table table_name AS WITH cte (col1) AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT col1 FROM cte

I couldn't think of a test case for the REPLACE statement, and for the CREATE VIEW ... WITH ... SELECT ... case, it will not output any errors even if the WITH statement is incorrect. (because view stm is not aware of the WITH parser) that's why I didn't add add a test cases for them. I've added the tests at iifawzi/sql-parser/support-with-statements.

We need to make other statements aware of the keyword. I will find some time to work on it.

@MauricioFauth
Copy link
Member

Closed by #363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants