Skip to content

feat: MERGE Statement Support (SQL:2003) #23

@productdevbook

Description

@productdevbook

Summary

Add MERGE statement support for upsert operations.

SQL:2003 Standard MERGE

MERGE INTO target USING source ON condition
WHEN MATCHED THEN UPDATE SET ...
WHEN NOT MATCHED THEN INSERT (cols) VALUES (vals)

Dialect Support

  • MSSQL: Full MERGE support
  • PostgreSQL: No MERGE (use INSERT ... ON CONFLICT)
  • MySQL: No MERGE (use INSERT ... ON DUPLICATE KEY UPDATE)
  • SQLite: No MERGE (use INSERT ... ON CONFLICT)

Design

  • Add MergeNode to AST
  • Printer generates MERGE for MSSQL, ON CONFLICT for PG/SQLite, ON DUPLICATE KEY for MySQL
  • Single builder API that abstracts dialect differences

Action Items

  • Add MergeNode to AST
  • Implement MergeBuilder with when/matched/notMatched API
  • Generate dialect-appropriate SQL
  • Test across all dialects

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitecture decisionsdialectDialect-specific

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions