fix: correct ALTER TABLE ADD IDENTITY column generation #195
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.
Implement Pretty Printing for ALTER TABLE ADD COLUMN Statements
Summary
This PR implements multi-line pretty printing for
ALTER TABLE ADD COLUMNstatements in the PostgreSQL deparser. Whencontext.isPretty()is enabled, column attributes (COLLATE, REFERENCES, UNIQUE, DEFAULT, GENERATED) are now formatted on separate indented lines for improved readability.Key formatting improvements:
NOT NULL,COLLATE,REFERENCES,UNIQUE,DEFAULT,GENERATEDmove to separate indented linesREFERENCES+ON DELETE CASCADE(split into separate lines)Review & Testing Checklist for Human
Recommended test plan: Run a variety of ALTER TABLE ADD COLUMN statements with different constraint combinations in both pretty and non-pretty modes, comparing outputs to ensure correctness.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD deparser["packages/deparser/src/deparser.ts<br/>AT_AddColumn case implementation"]:::major-edit test_file["packages/deparser/__tests__/pretty/<br/>alter-table-column.test.ts"]:::minor-edit snapshots["packages/deparser/__tests__/pretty/__snapshots__/<br/>alter-table-column.test.ts.snap"]:::minor-edit deparser --> test_file test_file --> snapshots subgraph "Key Logic Areas" pretty_logic["Pretty formatting logic<br/>context.isPretty() branching"]:::context constraint_handling["Constraint processing<br/>REFERENCES, UNIQUE, DEFAULT"]:::context indent_formatting["Indentation & newlines<br/>context.indent(), context.newline()"]:::context end deparser --> pretty_logic deparser --> constraint_handling deparser --> indent_formatting subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90,stroke:#333,stroke-width:2px classDef minor-edit fill:#87CEEB,stroke:#333,stroke-width:2px classDef context fill:#FFFFFF,stroke:#333,stroke-width:1pxNotes
(c: any)type annotation in constraints checking - this may indicate a need for better typing in the future