Skip to content

fix(splitter): keep CTE queries attached to inserts - #792

Open
edjubert wants to merge 1 commit into
supabase-community:mainfrom
edjubert:edjubert/splitter-insert-with-cte
Open

fix(splitter): keep CTE queries attached to inserts#792
edjubert wants to merge 1 commit into
supabase-community:mainfrom
edjubert:edjubert/splitter-insert-with-cte

Conversation

@edjubert

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

A valid INSERT INTO … WITH … SELECT statement is split after the target column
list because the statement splitter treats WITH as the start of a new
statement.

PostgreSQL then receives the incomplete INSERT INTO … (...) fragment and
reports syntax error at end of input.

What is the new behavior?

WITH is now handled like SELECT while splitting an INSERT, so a
CTE-backed insert remains a single statement until its terminating semicolon.

A regression test also verifies that a subsequent semicolon-terminated
statement is still split separately.

Additional context

Validated with:

cargo test -p pgls_statement_splitter
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings

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.

1 participant