fix: preserve num field in AlterTableCmd 14->15 transformation #200
+6
−2
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.
Fix: preserve num field in AlterTableCmd 14->15 transformation
Summary
Fixed an AST transformation mismatch where the
numfield was being dropped during PostgreSQL 14 to 15 AST transformation for ALTER INDEX statements. The issue occurred in theAlterTableCmdtransformation method which was explicitly preserving only certain fields but missing thenumfield.Root cause: The
AlterTableCmdmethod inv14-to-v15.tshad conditional field preservation logic but was missing handling for thenumfield, causing it to be dropped during transformation even though both PG14 and PG15 should have identical AST structures for this statement type.Changes made:
numfield preservation inAlterTableCmdtransformation methodlatest/postgres/create_index-345.sqlReview & Testing Checklist for Human
yarn test __tests__/kitchen-sink/14-15/latest-postgres-create_index.test.tspasses and specifically tests the SQLALTER INDEX concur_exprs_index_expr ALTER COLUMN 1 SET STATISTICS 100AlterTableCmdmethod to ensure no other fields are missing from the transformation logic (compare against PG14/PG15 type definitions)yarn testto ensure no regressions were introduced by preserving this fieldnumfield handling follows the same conditional preservation pattern as other fields in the methodDiagram
%%{ init : { "theme" : "default" }}%% graph TD TestFile["__tests__/kitchen-sink/14-15/latest-postgres-create_index.test.ts"]:::context SQL["ALTER INDEX ... ALTER COLUMN 1 SET STATISTICS 100"]:::context SkipList["test-utils/skip-tests/transformer-errors.ts"]:::minor-edit Transformer["src/transformers/v14-to-v15.ts:AlterTableCmd()"]:::major-edit TestFile --> SQL SQL --> Transformer SkipList -.-> TestFile Transformer --> |"Before: drops 'num' field"| BadAST["AST missing 'num': 1"]:::context Transformer --> |"After: preserves 'num' field"| GoodAST["AST with 'num': 1"]:::context 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