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

WITH ... AS ( DELETE ... RETURNING ) #1550

Open
dfcatdivvy opened this issue Jun 1, 2022 · 3 comments
Open

WITH ... AS ( DELETE ... RETURNING ) #1550

dfcatdivvy opened this issue Jun 1, 2022 · 3 comments
Assignees

Comments

@dfcatdivvy
Copy link

The following is valid in postgresql but gives an error in JSqlParser

WITH updated_rows AS (
    DELETE FROM documents WHERE something='something'
    RETURNING *
)
SELECT * FROM updated_rows LIMIT 1000;

Error:

net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "DELETE" "DELETE"
    at line 2, column 5.

Was expecting one of:

    "("
    "VALUE"
    "VALUES"
    "WITH"
    <K_SELECT>

	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:327)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:299)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:274)
	...
@manticore-projects
Copy link
Contributor

Greetings!

Thank you for reporting, you are right: WITH ... AS ( ... ) has been implemented as WITH ... AS ( SELECT ... ) only (because this the normal use-case). Although the RETURNING clause will make DELETE and INSERT and UPDATE relevant.

A major refactoring was needed.

@manticore-projects
Copy link
Contributor

Working now on it.

@manticore-projects
Copy link
Contributor

Duplicate #1916

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

2 participants