reference creatortrack postgres js date param bug 20260715T193334
In CreatorTrack (Next.js + postgres.js + drizzle), passing a raw JS Date object as a parameter into a postgres.js tagged-template raw-SQL query (e.g. a targeted jsonb_set(...) UPDATE written outside drizzle's query builder) throws ERR_INVALID_ARG_TYPE. Drizzle's typed .set() builder handles Date transparently, so this only surfaces when someone drops to raw SQL for a targeted/partial-column update (a common pattern when avoiding a full-column overwrite, see [[creatortrack_toctou_partial_update_race]]).
Fix: pass an ISO string with an explicit ::timestamptz cast instead of the bare Date object, e.g. ${date.toISOString()}::timestamptz.
Why worth keeping: surfaced 2026-07-15 while building the fix for Task 16's hand-edit race in the Scripts app (lib/scripts/profile.ts). Will bite again any time someone writes raw SQL against a timestamptz column in this codebase.
How to apply: when writing raw postgres.js SQL (not drizzle's builder) with a timestamp parameter, always stringify via .toISOString() and cast ::timestamptz rather than passing the Date object directly.
[auto-memory session 60d132de-4659-485c-8044-427af0ccce7f, confidence 0.75, mode staged]