Skip to content

pg-delta: integration tests for UNIQUE indexes with NULLS NOT DISTINCT (PG15+) #183

@avallete

Description

@avallete

Context

PostgreSQL 15+ allows CREATE UNIQUE INDEX ... NULLS NOT DISTINCT, which changes how duplicate NULL values are treated compared to a plain unique index. pg-delta already models nulls_not_distinct in the index catalog, recreates indexes when that attribute changes, and emits create SQL from the captured definition.

Gap

There is no integration coverage that proves roundtrip fidelity for this feature end-to-end (catalog -> diff -> apply -> re-read). If the clause were ever dropped or mishandled, uniqueness semantics could be silently weakened without an obvious failure mode.

Proposed work

  1. Add PostgreSQL 15+ integration tests that cover:
    • creating a unique index with NULLS NOT DISTINCT and verifying it survives a full declarative/diff roundtrip
    • transitioning between a plain unique index and the same index with NULLS NOT DISTINCT in both directions
  2. Only if a test fails, adjust index modeling / serialization / apply logic so the clause is preserved consistently.

Success criteria

  • Tests fail loudly if NULLS NOT DISTINCT is lost or incorrectly toggled.
  • The roundtrip no longer relies on manual inspection of generated SQL for this invariant.

Metadata

Metadata

Labels

🐛 BugDefects, regressions, or unintended behavior that need fixing

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions