You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bd22243
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen-ts): @autoset and plain field.timestamp now honor timestampMode
timestampMode:"date" already worked for the base Drizzle column type
(column-mapper.ts's mapColumnType) but two call sites still hardcoded
string-shaped output regardless:
1. drizzle-schema.ts's @autoset suffix always emitted
.$defaultFn(() => new Date().toISOString()) -- a string -- into a column
that's mode:"date" (expects a Date), a hard tsc failure
("Type 'string' is not assignable to type 'Date | SQL<unknown>'"),
cascading into every generated insert/update query touching the field.
2. zod-validators.ts's FIELD_SUBTYPE_TIMESTAMP case in zodFieldExpr, plus
its own 3 separate @autoset call sites, always emitted z.string() /
a string-returning transform -- disagreeing with the Drizzle column even
for a PLAIN (non-autoSet) timestamp field once timestampMode:"date" is
set, not just @autoset ones.
Both now branch on ctx.timestampMode: "date" -> new Date() / z.date()
(unchanged), "string" (default) -> the original .toISOString()/z.string()
behavior, byte-identical to before for every existing caller that doesn't
opt in.
field.date/field.time stay z.string() unconditionally -- calendar
date/time-of-day are inherently string-shaped on the wire, not governed by
timestampMode (which is specifically about field.timestamp's instant
representation).
Not touched: zodScalarFor() (used for field.map's valueType) still returns
z.string() for a timestamp-typed map value regardless of timestampMode --
narrower, unverified edge case, flagged rather than guessed at.
Reported and reproduced against an adopting project: real entity, real
`meta gen`, real `tsc --noEmit` failure before this fix, clean after.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C7jsHCMNVmaXu883UFsh1e
0 commit comments