fix(core): coerce calendarDay writes to Date before Prisma 7 validation#637
Conversation
… 7 validation Prisma 7's client validator rejects a bare YYYY-MM-DD string for a DateTime @db.Date column. Add a resolveInput hook that converts a valid string to a UTC-midnight Date before the write reaches Prisma, and widen the field's zod schema to accept either shape (resolveInput runs before validation in the write pipeline). Closes #621
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: f38867e The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
ReviewOverviewFixes #621: Correctness
Minor observation (non-blocking)For a value that's neither a valid Test coverageStrong — new tests cover the Style / conventions
RiskLow. Change is scoped to a single field builder, additive to the hook object (still overridable by user-provided hooks per the existing merge pattern), and read behavior is untouched. All 752 core tests + typecheck + lint pass. No blocking issues found. Generated by Claude Code |
Coverage Report for Core Package Coverage (./packages/core)
File CoverageNo changed files found. |
Coverage Report for UI Package Coverage (./packages/ui)
File CoverageNo changed files found. |
Coverage Report for CLI Package Coverage (./packages/cli)
File CoverageNo changed files found. |
Coverage Report for Auth Package Coverage (./packages/auth)
File CoverageNo changed files found. |
Coverage Report for Storage Package Coverage (./packages/storage)
File CoverageNo changed files found. |
Coverage Report for RAG Package Coverage (./packages/rag)
File CoverageNo changed files found. |
Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)
File CoverageNo changed files found. |
Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)
File CoverageNo changed files found. |
Summary
calendarDay()gained a field-levelresolveInputhook that converts a validYYYY-MM-DDstring to a UTC-midnightDatebefore the write reaches Prisma. Prisma 7's client validator rejects a bare date string for aDateTime @db.Datecolumn, so the documented string-write path was 500ing (calendarDay write to Prisma 7 @db.Date still 500s: #602 added the string type + read normaliser but no write-side string→Date coercion (#571 regression) #621, a regression from Release: Validation & field-type input parity (zod 4.4 + calendarDay) — PRD #582 #602).resolvedData[fieldKey](not rawinputData), so a list-levelresolveInputthat injects a default for an omitted key still gets coerced instead of being overwritten withnull.null/undefined, and already-Datevalues pass through the hook unchanged so existing validation (isRequired, format errors) is unaffected.z.union([stringSchema, z.date()])since a successful write now reaches validation as aDate(resolveInput runs before validation in the write pipeline).resolveOutputstill normalises back to aYYYY-MM-DDstring.Test plan
resolveInputhook (string→Date coercion, pass-through cases, readingresolvedDatavsinputData)context.db.event.create/updateagainst a mocked Prisma client asserting the value forwarded to Prisma is aDate, reproducing the issue's repro scenariopnpm test(packages/core) — 752 passedpnpm lint,pnpm manypkg fix,pnpm formattsc --noEmitCloses #621
Generated by Claude Code