Skip to content

Commit 355d20a

Browse files
Version Packages (#30)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ac42853 commit 355d20a

3 files changed

Lines changed: 53 additions & 53 deletions

File tree

.changeset/datetime-back-to-datefromself.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
# Changelog
22

3+
## 5.8.0
4+
5+
### Minor Changes
6+
7+
- ac42853: fix: DateTime maps back to `Schema.DateFromSelf` (Date ↔ Date) — Prisma+Kysely canonical
8+
9+
Reverts the 5.6.0 change that mapped `DateTime` to `DateFromInput` (a
10+
`Schema.Union(DateFromSelf, Date)` with `Encoded = Date | string`).
11+
12+
**Why revert**: the dual-input Union pushed the boundary problem onto
13+
DA-layer consumers. Kysely's pg driver returns native `Date` instances,
14+
but `Selectable<X>.created_at` typed as `Date | string` forced every DA
15+
mapper that copies `result.created_at` into a contract type to either
16+
narrow manually (no cast-free path) or wrap the read in
17+
`Schema.decode(Selectable(X))` (heavy refactor across hundreds of sites).
18+
19+
**Why DateFromSelf is correct**:
20+
- **Prisma docs**: _"Prisma Client returns all DateTime values as native
21+
JavaScript Date objects. ... DateTime values must be passed as Date
22+
objects, not strings, to avoid runtime errors."_
23+
- **Kysely docs**: idiomatic DateTime column is
24+
`created_at: ColumnType<Date, string | undefined, never>` — SELECT
25+
yields `Date`. _"TypeScript is a compile-time concept and cannot
26+
alter runtime JavaScript types. If your TypeScript definition for a
27+
column differs from the database's actual return type, the runtime
28+
type will not change automatically."_
29+
- **Effect Schema docs (Doc 10944)**: _"schemas should be defined such
30+
that encode + decode return the original value"_ — one Type, one
31+
Encoded per schema. The dual-boundary problem (DA Date ↔ Date vs
32+
RPC string ↔ Date) is solved by **two schemas** (one per boundary),
33+
not one Union. Doc 4312 (`@effect/sql/Model.Class`) shows this
34+
canonical variant pattern (`select`/`insert`/`update` vs
35+
`json`/`jsonCreate`/`jsonUpdate`).
36+
37+
**For RPC/HTTP wire boundaries**: define a contract-layer schema that
38+
overrides date columns with `Schema.Date` (Encoded = string) before the
39+
RPC framework calls `Schema.decode`. This is the same pattern as
40+
`@effect/sql`'s `json` variants — one schema per boundary.
41+
42+
**`DateFromInput` is still exported** from the package for consumers that
43+
specifically want the dual-input behavior at a single call site. The
44+
codegen just no longer auto-emits it for every DateTime column.
45+
46+
**The Schema.Schema.Encoded fix in 5.7.0 stays** — that's still correct
47+
for join-table column exposure (`_product_tags.A`/`B`).
48+
49+
**Migration**: most consumers benefit immediately (DA mappers stop
50+
seeing `Date | string`). For RPC contracts that previously didn't have
51+
a Date override (because they relied on `DateFromInput`), re-add a
52+
`Schema.extend` with `Schema.Date` overrides for date columns to keep
53+
wire decode working.
54+
355
## 5.7.0
456

557
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prisma-effect-kysely",
3-
"version": "5.7.0",
3+
"version": "5.8.0",
44
"description": "Prisma generator that creates Effect Schema types from Prisma schema compatible with Kysely",
55
"license": "MIT",
66
"author": "Samuel Ho",

0 commit comments

Comments
 (0)