[BUG]: UpstashCache.put throws Do not know how to serialize a BigInt with the effect-postgres adapter (int8 columns decode to BigInt)

Author: rohovskoiCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

1.0.0-rc.5-ab785fc

What version of drizzle-kit are you using?

1.0.0-rc.5-ab785fc

Other packages

No response

Describe the Bug

What's happening

With [email protected] and the drizzle-orm/effect-postgres adapter on top of @effect/[email protected], every cache write for a query touching an int8/bigserial column fails:

  TypeError: Do not know how to serialize a BigInt
      at JSON.stringify (<anonymous>)
      at HSetCommand.defaultSerializer [as serialize] (@upstash/redis)
      at new HSetCommand (@upstash/redis)
      at Pipeline.hset (@upstash/redis)
      at UpstashCache.put (drizzle-orm/src/cache/upstash/cache.ts:176)

Root cause

  1. @effect/sql-pg rc.118 ships a new native wire-protocol driver that decodes int8 columns to native JS BigInt (binary format, getBigInt64). Previously (node-postgres-based) int8 arrived as a string and drizzle's column mapping handled it.
  2. UpstashCache.put(key, response, ...) passes the raw response rows straight through to redis.pipeline().hset(...) without making them JSON-safe. @upstash/redis serializes with JSON.stringify, which throws on BigInt.

So any cached query touching a bigint/bigserial column now fails the cache write (logged as Drizzle cache put failed), and caching silently stops working for those queries.

Expected behavior

UpstashCache should serialize its payload BigInt-safely — e.g. recursively convert BigInt → Number/string in put, or expose a pluggable serializer. @effect/sql-pg's BigInt decoding for int8 is correct and by design; the cache adapter should tolerate arbitrary driver output.

Reproduction

Workaround

Wrap UpstashCache and sanitize the response before super.put (deep-walk bigint → Number). Works, but every consumer of the effect-postgres + Upstash-cache combo has to reinvent it.

Suggested fix

In drizzle-orm/src/cache/upstash/cache.ts put()/onMutate(): deep-convert BigInt values (or pass a BigInt-safe replacer to the serializer) before handing off to hset. Alternatively, @upstash/redis could serialize BigInt as string — but since the values come from drizzle, sanitizing in UpstashCache is the safer fix (keeps cache-hit and cache-miss row shapes consistent).

Source: drizzle-team/drizzle-orm