feat: improve PG13->PG14 AST conversion with context-aware transformations #171
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.
feat: improve PG13->PG14 AST conversion with context-aware transformations
Summary
This PR improves the PostgreSQL 13 to 14 AST conversion in the transform package by implementing context-aware transformation logic and better enum handling. The changes maintain the current test pass rate of 234/258 tests (90.7%) while addressing several categories of transformation issues.
Key improvements:
CREATE_TABLE_LIKE_COMPRESSIONContext: The transformer handles complex version-specific differences between PostgreSQL 13 and 14 ASTs, requiring nuanced understanding of when to preserve vs transform enum values based on the surrounding AST context.
Review & Testing Checklist for Human
Recommended test plan: Run the transformer on a diverse set of PostgreSQL 13 DDL statements (CREATE FUNCTION, CREATE AGGREGATE, ALTER statements) and verify the resulting AST can be successfully parsed by PostgreSQL 14.
Diagram
graph TD subgraph "Transform Package" A[RULES.md]:::major-edit B[v13-to-v14.ts]:::major-edit C[13/enums.ts]:::context D[14/enums.ts]:::context end subgraph "Test Suite" E[kitchen-sink/13-14 tests]:::context F[234/258 passing]:::context end subgraph "Key Methods Modified" G[FunctionParameter]:::major-edit H[TableLikeClause]:::major-edit I[FuncCall]:::major-edit J[ObjectWithArgs]:::major-edit end B --> G B --> H B --> I B --> J C --> B D --> B E --> B subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/38143a4f464f44999273813aecad7368
Requested by: Dan Lynch (@pyramation)