reference postgres js date param binding bug 20260715T194211
When writing raw SQL via the postgres npm package's sql\...`tagged templates in CreatorTrack, passing a bare JSDateobject as a bound parameter throwsERR_INVALID_ARG_TYPE. This does not happen through drizzle's typed.set()` query builder, only through raw parameterized SQL.
Fix: convert to an ISO string and cast explicitly in the query, e.g. ${date.toISOString()}::timestamptz, rather than passing the Date object directly.
Why: Surfaced while building a targeted jsonb_set UPDATE (lib/scripts/profile.ts) to fix a TOCTOU race in CreatorTrack's Scripts app voice-profile regenerate path. Would otherwise cost debugging time again on any future raw-SQL write involving a timestamp.
How to apply: Any time a raw sql\...`query (not the drizzle builder) needs to bind a Date, convert to ISO string +::timestamptz` cast up front instead of rediscovering the ERR_INVALID_ARG_TYPE failure.
[auto-memory session 60d132de-4659-485c-8044-427af0ccce7f, confidence 0.70, mode staged]