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 18f5f36
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen-ts): read field attributes via effective attr(), not ownAttr() (#55)
Field-level `extends` (abstract fields — a concrete field extending a package-level
abstract field to inherit `required` / `maxLength` / `default` / etc.) was silently
dropping the inherited attributes: the generators read them with `ownAttr()` (own
declarations only), so an inherited `@required` produced a NULLABLE column, an
inherited `@maxLength` was ignored, etc. Output was under-constrained — e.g. a field
`{ extends: Name }` of an abstract `Name {required, maxLength:200}` generated
`text("name")` instead of `varchar("name",{length:200}).notNull()`.
This surfaced after the collect-all rework (#52) made inherited attrs resolve as
effective-but-not-own; the generators' long-standing `ownAttr()` usage then missed
them. Switched every FIELD_ATTR_* read (57 sites across column-mapper, drizzle-schema,
zod-validators, inferred-types, entity-constants, filters, payload/extract, docs, …)
to the effective `attr()`. For a field with no `extends`, `attr() === ownAttr()`, so
this is a no-op for all existing output (codegen-ts 803/0, byte-identical goldens);
it only restores the inherited case. Identity/object/source/validator reads stay
`ownAttr()` (correctly own-only).
Also: buildFkMapForEntity now strips the package from the FK target before the lookup
(`findObject(stripPackage(targetName))`) — the YAML front-end resolves `@references`
to an FQN (`pkg::Entity`), and the un-stripped lookup dropped every FK under YAML.
Mirrors the relation-resolver, which already strips.
Tests: a YAML fixture exercising both (abstract-field required+maxLength inheritance,
and a package-qualified FK target). codegen-ts 803/0.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments