Skip to content

fix(deparser): MergeWhenClause support and SecLabelStmt qualified object names#304

Merged
pyramation merged 1 commit into
mainfrom
feat/deparser-merge-seclabel
Jul 20, 2026
Merged

fix(deparser): MergeWhenClause support and SecLabelStmt qualified object names#304
pyramation merged 1 commit into
mainfrom
feat/deparser-merge-seclabel

Conversation

@pyramation

Copy link
Copy Markdown
Collaborator

Summary

Two pgsql-deparser bugs found while fuzzing constructive-db's schema transform:

  1. Top-level MERGE could not deparse at allMergeStmt visited its mergeWhenClauses, but there was no MergeWhenClause visitor, so every MERGE failed with Deparser does not handle node type: MergeWhenClause. Added the visitor covering:

    • MERGE_WHEN_MATCHED / NOT MATCHED [BY TARGET] / NOT MATCHED BY SOURCE
    • AND <condition>
    • CMD_UPDATE (UPDATE SET via the same ResTarget/update context as UpdateStmt), CMD_INSERT (columns, OVERRIDING {USER|SYSTEM} VALUE, VALUES (...) / DEFAULT VALUES), CMD_DELETE, CMD_NOTHING (DO NOTHING)
    • also added MergeStmt.returningList handling (MERGE ... RETURNING, PG17)
  2. SecLabelStmt emitted invalid qualified namesSECURITY LABEL ... ON COLUMN a.b.c deparsed to ON COLUMN "a", b, c because the object List was visited generically (comma-joined). Now dot-joined, matching CommentStmt's existing handling.

Fixtures added via the kitchen-sink pipeline (__fixtures__/kitchen-sink/misc/merge-seclabel.sql, 8 statements round-tripped in both plain and pretty modes). Full deparser suite passes (713 tests).

Link to Devin session: https://app.devin.ai/sessions/eeb8deba0c04475091df703c88877302
Requested by: @pyramation

@pyramation pyramation self-assigned this Jul 20, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit a0033bd into main Jul 20, 2026
9 checks passed
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