feat(mysql): improve AST formatting and add DELETE JOIN support #4206
+1,304
−70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR continues the MySQL AST formatting work with several improvements:
New AST Nodes
VariableExpr- MySQL user variables (@var), distinct from sqlc's@paramsyntaxIntervalExpr- MySQL INTERVAL expressionsOnDuplicateKeyUpdate- MySQL ON DUPLICATE KEY UPDATE clauseParenExpr- Explicit parentheses for expression groupingDELETE with JOIN Support
DeleteStmtwithTargetsandFromClausefieldsDELETE t1.*, t2.* FROM t1 JOIN t2 ON ...compiler/output_columns.goto handle new structure for table resolutionBug Fixes
@variablenow preserved as-is in output (not treated as sqlc named parameter)sqlc.arg()handling in ON DUPLICATE KEY UPDATE clause by adding field to rewrite traversalDocumentation
Added CLAUDE.md files documenting key packages:
internal/sql/ast/- AST nodes and formattinginternal/sql/astutils/- Walk and Apply functionsinternal/sql/named/- Named parameter detectioninternal/sql/rewrite/- Parameter rewritinginternal/engine/dolphin/- MySQL/TiDB conversion patternsTest plan
TestFormattests pass (including previously failing delete_join tests)TestReplaytests pass🤖 Generated with Claude Code