Skip to content

chore(deps): upgrade sqlparser 0.55 to 0.62 - #149

Closed
Blankll wants to merge 1 commit into
fix/with-dml-classificationfrom
chore/sqlparser-0.62
Closed

chore(deps): upgrade sqlparser 0.55 to 0.62#149
Blankll wants to merge 1 commit into
fix/with-dml-classificationfrom
chore/sqlparser-0.62

Conversation

@Blankll

@Blankll Blankll commented Sep 3, 2026

Copy link
Copy Markdown
Member

Stacked on #147

This PR builds on fix/with-dml-classification (#147): its recursive classifier is what consumes the newly-parseable statement shapes. Merge #147 first.

Why upgrade

sqlparser 0.55 cannot parse WITH … DELETE, WITH … MERGE, or DELETE/MERGE inside a CTE body — all valid PostgreSQL (and SQL Server, for DELETE/MERGE-with-CTE). The MCP classifier (classify_sql) therefore fails closed with a parse error for those statements, making sqlkit__execute_delete unusable for them.

sqlparser 0.62 parses all of them, representing the top-level DML as Query { body: SetExpr::Delete/Merge(Statement) } (mirroring the existing SetExpr::Insert/Update shape).

Changes

  • Cargo.toml: sqlparser 0.55 → 0.62
  • capabilities/sql_write.rs:
    • classifier gains SetExpr::Delete / SetExpr::Merge arms → WITH … DELETE routes to Delete, WITH … MERGE to Write
    • the 0.55 SET-family Statement variants (SetVariable/SetNames/SetNamesDefault/SetRole/SetSessionParam/SetTimeZone/SetTransaction) consolidated into Statement::Set
  • database/sql_service.rs: SelectItem gained ExprWithAliases (Spark) — column extraction uses its first alias, falling back to the expression name

Tests

  • New: classifies_with_delete_as_delete (top-level WITH … DELETE + DELETE-in-CTE-returning), classifies_with_merge_as_write
  • Full lib suite: 367 passed / 0 failed (16 classifier tests)
  • cargo fmt --check clean on changed files; no new clippy warnings

0.62 parses statement shapes 0.55 could not: `WITH ... DELETE`,
`WITH ... MERGE` and DELETE/MERGE inside CTE bodies are now valid ASTs
(Query body carries SetExpr::Delete/SetExpr::Merge), so the MCP classifier
no longer fails closed on them. The recursive classifier gains the
Delete/Merge arms (both the statement body and nested CTE positions) and
routes them to execute_delete / execute_write respectively.

Migration for breaking AST changes:
- sql_write.rs: the 0.55 SET-family variants (SetVariable, SetNames,
  SetNamesDefault, SetRole, SetSessionParam, SetTimeZone, SetTransaction)
  are consolidated into Statement::Set
- sql_service.rs: SelectItem gained ExprWithAliases (Spark) - projected
  names now use its first alias, falling back to the expression name

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@Blankll Blankll closed this Sep 3, 2026
@Blankll
Blankll deleted the chore/sqlparser-0.62 branch September 3, 2026 16:36
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