Support parsing data-modifying statements in WITH
- Dominant language
- Clojure
- Stars
- 23
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
[This is legal in Postgres](https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-MODIFYING)
But fails
```
(deftest complicated-mutations-test
(is (= #{"delete" "insert"}
(mutations "WITH outdated_orders AS (
DELETE FROM orders
WHERE
date <= '2018-01-01'
RETURNING *
)
INSERT INTO order_log
SELECT * from outdated_orders;"))))
```
with
```
macaw.core-test
1 non-passing tests:
Error in complicated-mutations-test
expected: (=
#{"delete" "insert"}
(mutations
"WITH outdated_orders AS (
DELETE FROM orders
WHERE
date <= '2018-01-01'
RETURNING *
)
INSERT INTO order_log
SELECT * from outdated_orders;"))
error: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "DELETE" "DELETE"
at line 2, column 24.
Was expecting:
"WITH"
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the failing complicated-mutations-test in macaw.core-test and run it to reproduce the JSQLParser error for a DELETE inside WITH. Trace the mutations entry point and parser integration, then update coverage so the statement is recognized as both delete and insert and the test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100