Skip to content

feat(postgresql): add MERGE support#4517

Open
taua-almeida wants to merge 1 commit into
sqlc-dev:mainfrom
taua-almeida:feat/postgresql-merge-support
Open

feat(postgresql): add MERGE support#4517
taua-almeida wants to merge 1 commit into
sqlc-dev:mainfrom
taua-almeida:feat/postgresql-merge-support

Conversation

@taua-almeida

Copy link
Copy Markdown

Summary

  • add PostgreSQL MERGE parsing, AST traversal, formatting, analysis, and code-generation support
  • infer parameters across source queries, join conditions, WHEN conditions, updates, and inserts
  • support RETURNING, including source-before-target star expansion, NOT MATCHED BY SOURCE nullability, and typed merge_action()
  • add documentation and end-to-end coverage for database/sql, pgx/v4, and pgx/v5

Fixes #2272

Test plan

  • go test ./internal/compiler ./internal/engine/postgresql ./internal/sql/...
  • MERGE end-to-end replay tests
  • MERGE and UPDATE formatter round-trip tests
  • go test ./... -run '^$'
  • git diff --check
  • make build-endtoend
  • full go test ./... using PostgreSQL 16.14 for base and managed-db contexts

MERGE ... RETURNING, merge_action(), and NOT MATCHED BY SOURCE fixtures remain base-only because those features require PostgreSQL 17 or later.

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.

Add MERGE INTO support

1 participant