Support non-destructive custom field injection in generated models (for computed/scan-only columns) #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When using ResolveSpec + relspec code generation for Bun models, we need a stable way to add custom fields (like computed columns) that are not present in DB schema tables, without those changes being overwritten on regeneration.
Current generated models are fully replaced each run, so teams must maintain local patch scripts. This is brittle and easy to miss in CI/CD.
Problem / Motivation
A common UI/API pattern is requesting computed columns, e.g.:
thought_count = COALESCE((SELECT COUNT(*) FROM thoughts t WHERE t.project_id = projects.guid), 0)ResolveSpec returns this column, but Bun scan fails unless the target model includes a matching field.
Without first-class extension points, generated model edits are lost after each
relspec convert.Current Failure Example
Minimal Repro
relspec convert --to bun ...).ModelPublicProjectsin ResolveSpec.thought_count.ThoughtCount spectypes.SqlInt64 \bun:"thought_count,scanonly" json:"thought_count"``Expected Behavior
ResolveSpec/relspec should provide a supported mechanism to preserve custom model additions across regeneration.
Feature Request (Preferred Options)
Embedding/partial extension points in generated model output
Generator-level custom field config
bun:"...,scanonly",json:"...")Schema annotation support
Post-generation patch hook support
--post-hook/ patch plugin pipeline so customizations are first-class and repeatable.Why This Matters
Environment
v1.0.86computedColumnsonprojectsentity