Skip to content

fix(postgrest): accept CLI-generated types in insert/upsert/update - #1613

Open
twelfthlabor wants to merge 1 commit into
supabase:mainfrom
twelfthlabor:fix/typeddict-insert-1443
Open

fix(postgrest): accept CLI-generated types in insert/upsert/update#1613
twelfthlabor wants to merge 1 commit into
supabase:mainfrom
twelfthlabor:fix/typeddict-insert-1443

Conversation

@twelfthlabor

Copy link
Copy Markdown

Issue: insert/upsert/update type their body as JSON, so CLI-generated TypedDicts with datetime/date/time/UUID/Decimal fields fail type checking (#1443). Widening the alias alone is not sufficient: httpx serializes json= with stdlib json.dumps, which raises TypeError on those values at request time.

Fix:

  • Add a JSONSerializable input alias for write operations. The strict JSON alias is unchanged, so response validation stays strict.
  • Normalize outbound bodies to JSON-safe primitives via pydantic in RequestConfig (datetime to ISO strings, UUID/Decimal to strings). Plain JSON passes through unchanged. The httpx request path itself is unchanged.

Tests: insert/upsert/update with datetime, date, time, UUID, and Decimal values, plus TypedDict validation and a plain-JSON unchanged case, in both sync and async suites. ruff and mypy clean.

Fixes #1443

insert/upsert/update typed their body as JSON, so CLI-generated TypedDicts with datetime/date/time/UUID/Decimal fields failed type checking. Widening the alias alone is not enough: httpx serializes json= with stdlib json.dumps, which raises TypeError on those values at runtime.

Add a JSONSerializable input alias (strict JSON type left unchanged for response validation) and normalize outbound bodies to JSON-safe primitives via pydantic in RequestConfig, keeping the httpx request path as-is.

Fixes supabase#1443
@twelfthlabor
twelfthlabor requested review from a team and o-santi as code owners September 4, 2026 02:00
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.

insert does not expect TypedDict provided by generated types

1 participant