Skip to content

test(supabase_typegen): pin key-column write behaviors of the generated value types - #1778

Draft
spydon wants to merge 2 commits into
feat/supabase-genfrom
test/typed-key-column-writes
Draft

test(supabase_typegen): pin key-column write behaviors of the generated value types#1778
spydon wants to merge 2 commits into
feat/supabase-genfrom
test/typed-key-column-writes

Conversation

@spydon

@spydon spydon commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Tests only, stacked on #1635. Regression coverage for the typed-write semantics that supabase-swift recently had to fix after shipping its typed PostgREST layer:

  • supabase-swift#1278 — the primary key must be optional in Insert, not absent, or compound natural keys become unwritable and upsert silently degrades to insert-only.
  • supabase-swift#1280Update must be able to change a key column.
  • supabase-swift#1281 — a typed update must be able to write SQL NULL to a nullable column.

Why no code changes?

The generator in #1635 never had these bugs. It derives writability purely from column metadata with postgres-meta's rule (optional exactly when nullable, identity, or covered by a default) and never consults the primary key, which is the end state the Swift fixes converged to. The null-versus-omit ambiguity is solved by the set…ToNull copies, which #1635 already tests.

What was missing is tests locking in the two key-column capabilities, so a future refactor that starts filtering key columns (the mistake Swift made) fails loudly:

  • insert can carry an explicitly chosen key column — an identity-by-default id passed explicitly reaches the request body.
  • upsert merges on key columns carried by the insert values — bulk upsert sends the keys in every row, the columns parameter includes them, and resolution=merge-duplicates is set, so the merge half of upsert is reachable.
  • update can change a key columnBooksUpdate(id: 2) patches the key while the filter still targets the old value.

The third Swift fix maps onto the existing setXToNull writes SQL NULL explicitly test, so no new test was needed for it.

Test plan

  • dart test in packages/supabase_typegen — 36 tests pass
  • dart analyze — no issues
  • dart format — no diff

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant