fix: resolve 15-16 transformer AST mismatch for create_view-281.sql#202
Merged
pyramation merged 3 commits intomainfrom Jul 1, 2025
Merged
fix: resolve 15-16 transformer AST mismatch for create_view-281.sql#202pyramation merged 3 commits intomainfrom
pyramation merged 3 commits intomainfrom
Conversation
- Add SYSTEM_USER transformation handling in ColumnRef, FuncCall, and RangeVar methods
- Fix empty object handling in List transformation to use {} as any instead of { A_Const: {} }
- Remove skip entry for latest/postgres/create_view-281.sql test case
The transformer now correctly handles:
- PG15 ColumnRef with system_user -> PG16 FuncCall with pg_catalog.system_user
- PG15 FuncCall with pg_catalog.system_user -> PG16 ColumnRef with system_user
- PG15 RangeVar with system_user -> PG16 RangeFunction with nested FuncCall
- Empty objects in List items to match native PG16 AST output
Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Restore nulls_not_distinct property transformation in IndexStmt method - Fixes regression introduced in previous commit that broke CREATE INDEX tests - Both create_view-281.sql and create_index tests now pass Co-Authored-By: Dan Lynch <pyramation@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: resolve 15-16 transformer AST mismatch for create_view-281.sql
Summary
This PR fixes a critical AST transformation mismatch in the PostgreSQL 15-to-16 transformer that was causing the
latest/postgres/create_view-281.sqltest case to fail. The issue was related to howSYSTEM_USERreferences are transformed between PostgreSQL versions.The root cause was that PostgreSQL 15 and 16 represent
SYSTEM_USERdifferently in their ASTs:ColumnReffor direct references,RangeVarfor table-like usageFuncCallwithpg_catalog.system_userfor both cases, orRangeFunctionfor table-like usageThe complex CREATE VIEW SQL statement contained multiple forms of
SYSTEM_USERusage that required bidirectional transformation logic to handle all cases correctly.Review & Testing Checklist for Human
ColumnRef↔FuncCallandRangeVar↔RangeFunctiontransformations are complex. Review the logic in both directions to ensure they're consistent and handle edge cases.SYSTEM_USERto ensure this fix doesn't break existing functionality.{} as anychange in theListmethod affects many AST nodes. Spot-check a few other transformer tests to ensure no regressions.Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "Test Infrastructure" A["transformer-errors.ts"]:::minor-edit B["latest-postgres-create_view.test.ts"]:::context end subgraph "Core Transformer" C["v15-to-v16.ts"]:::major-edit D["ColumnRef method"]:::major-edit E["FuncCall method"]:::major-edit F["RangeVar method"]:::major-edit G["List method"]:::minor-edit H["IndexStmt method"]:::minor-edit end subgraph "SQL Query" I["CREATE VIEW with SYSTEM_USER"]:::context J["Direct SYSTEM_USER references"]:::context K["SELECT * FROM SYSTEM_USER"]:::context end A --> C B --> C C --> D C --> E C --> F C --> G C --> H I --> J I --> K J --> D J --> E K --> F 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
IndexStmtby accidentally removingnulls_not_distincthandling, which I caught and fixed in a follow-up commit.create_view-281.sqltest case.