Skip to content

Conversation

@pyramation
Copy link
Collaborator

@pyramation pyramation commented Jul 1, 2025

fix: add missing nulls_not_distinct property to IndexStmt transformer

Summary

Fixed a transformer issue where CREATE INDEX statements with NULLS NOT DISTINCT clause were failing in the PostgreSQL v15-to-v16 transformer. The IndexStmt transformer was missing the nulls_not_distinct property handling, causing test cases like create_index-72.sql to be skipped.

Changes:

  • Added nulls_not_distinct property handling to the IndexStmt transformer in v15-to-v16.ts
  • Enabled 4 previously skipped CREATE INDEX test cases by commenting out their entries in transformer-errors.ts
  • All 267 transformer tests now pass, confirming no regressions

Review & Testing Checklist for Human

Risk Level: 🟡 Medium - Simple change following established patterns, but limited validation of SQL syntax and type definitions

  • Verify type definitions: Check that nulls_not_distinct property exists in both PG15 and PG16 IndexStmt type definitions in the schema files
  • Test actual SQL syntax: Examine one of the previously failing SQL files (e.g., latest/postgres/create_index-72.sql) to understand the exact CREATE INDEX syntax being transformed
  • Run focused test: Test just one of the previously failing cases in isolation to verify the transformation works correctly
  • Check for other missing properties: Compare the IndexStmt transformer with similar transformers (like Constraint) to see if other properties are missing
  • End-to-end verification: Create a test script with CREATE UNIQUE INDEX idx ON tbl (col) NULLS NOT DISTINCT syntax and verify it transforms correctly

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    subgraph "Transform Package"
        V15ToV16["packages/transform/src/transformers/v15-to-v16.ts"]:::major-edit
        Errors["packages/transform/test-utils/skip-tests/transformer-errors.ts"]:::minor-edit
        Tests["packages/transform/__tests__/kitchen-sink/15-16/latest-postgres-create_index.test.ts"]:::context
    end
    
    subgraph "SQL Test Files"
        SQL72["latest/postgres/create_index-72.sql"]:::context
        SQL83["latest/postgres/create_index-83.sql"]:::context
        SQL85["latest/postgres/create_index-85.sql"]:::context
        SQL184["latest/postgres/create_index-184.sql"]:::context
    end
    
    V15ToV16 -->|"transforms"| SQL72
    V15ToV16 -->|"transforms"| SQL83
    V15ToV16 -->|"transforms"| SQL85
    V15ToV16 -->|"transforms"| SQL184
    
    Tests -->|"runs"| SQL72
    Tests -->|"runs"| SQL83
    Tests -->|"runs"| SQL85
    Tests -->|"runs"| SQL184
    
    Errors -->|"controls skipping"| Tests
    
    subgraph Legend
        L1["Major Edit"]:::major-edit (green)
        L2["Minor Edit"]:::minor-edit (blue)
        L3["Context/No Edit"]:::context (white)
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • The fix follows the exact same pattern used in the Constraint transformer where nulls_not_distinct is already properly handled
  • CREATE INDEX with NULLS NOT DISTINCT is a PostgreSQL feature for unique indexes that treats NULL values as distinct from each other
  • This was requested by Dan Lynch ([email protected]) in Devin session: https://app.devin.ai/sessions/648fc5d6fb81492ab99b6e870f13ad3b
  • All 267 v15-to-v16 transformer tests pass after this change, indicating no regressions

@devin-ai-integration
Copy link
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 and CI monitoring

- Add nulls_not_distinct property handling in v15-to-v16 IndexStmt transformer
- Enable previously skipped CREATE INDEX test cases with NULLS NOT DISTINCT
- Fixes transformer failures for create_index-72.sql, create_index-83.sql, create_index-85.sql, create_index-184.sql

Co-Authored-By: Dan Lynch <[email protected]>
@pyramation pyramation force-pushed the pg/create-index-72 branch from 3c6ce29 to 07c0ab4 Compare July 1, 2025 06:18
@pyramation pyramation merged commit d7f2d15 into main Jul 1, 2025
1 check 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.

2 participants