Skip to content

fix: --prove reads a constant array cast whole or element by element alike - #154

Merged
jasdeepkhalsa merged 1 commit into
mainfrom
fix/prove-array-casts
Oct 21, 2026
Merged

jasdeepkhalsa merged 1 commit into
mainfrom
fix/prove-array-casts

Conversation

@jasdeepkhalsa

Copy link
Copy Markdown
Member

PostgreSQL prints kind IN ('web', 'shop') on a varchar column with the cast on the whole array, (ARRAY['web'::character varying, …])::text[]. SQL written from that print can come back with the cast on each element instead, ARRAY[('web'::character varying)::text, …]. Both forms are stable from then on.

A CHECK, index or policy made from a previous sync's SQL therefore never read like the source's, and --prove refused correct migrations because of it. The proof now reads the two spellings as one: in its fingerprint comparison, and in constraint, index and policy definitions. Only arrays of quoted constants are rewritten; for those, casting the array and casting each element are the same.

Tests:

  • New unit tests for the rewrite, including that arrays of anything but constants are left alone.
  • The sb17>pg17 matrix pair, where this was found, now proves its drift phase on freshly started servers.
  • The unit suite and lint pass.

Fixes #151

🤖 Generated with Claude Code

…alike

`kind IN ('web', 'shop')` on a varchar column is printed with the cast
on the whole array, but SQL written from that print can come back with
the cast on each element; both are stable from then on. A CHECK, index
or policy made from a previous sync's SQL never read like the source's,
so the proof refused correct migrations on it. Both spellings are now
read as one where the proof compares: for an array of constants,
casting the array and casting each element are the same.

Fixes #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasdeepkhalsa
jasdeepkhalsa merged commit 9e71346 into main Oct 21, 2026
28 checks 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.

--prove: an IN-list CHECK rendered once more on the target reads as changed

1 participant