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 70e29fa
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen): a view over an int-backed enum emitted a codec it never declared
A `field.enum` carrying `@intValueMap` persists as an integer column, and the
entity's Drizzle table declares a module-local `customType` codec to encode and
decode it. The view path emitted the CALL SITE only and let the codec's const
name fall through to the drizzle core import, so a projection module opened with
import { statusIntEnum } from "drizzle-orm/sqlite-core";
naming a member that package does not export. `meta gen` exited 0; only a
typecheck caught it (TS2305). Both view hosts were affected — an
`object.projection` and a write-through entity's replica view render through the
same `renderExistingViewDecl` — and the read-view is the shape the authoring
guidance recommends over a projection.
The codec emitter moves to a shared `templates/enum-int-codec.ts` and the view
now declares what it references. Because a write-through entity puts its table
and its replica view in ONE module, the table is rendered first, reports the
const names it declared, and the view references those instead of re-declaring
them: a duplicate module-scope `const` is a JS parse error, and a declaration
emitted after its use is a TDZ ReferenceError at import — both worse than the
missing codec, since neither lets the module load at all.
No fixture combined `@intValueMap` with a read-only source, which is why the
suite was green. Two added tests compile the generated output with the real TS
compiler, on both dialects.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JGmCLHbQKuLBPjjhWC43jk
0 commit comments