Skip to content

Commit ca0a1f8

Browse files
claudeos-zhuang
authored andcommitted
feat(showcase): demonstrate a multi-value reference seed (#3911)
`field_zoo` covered every field type with a real seeded value EXCEPT a multi-value reference — the one shape #3911 was about. Adds `f_lookups: Field.lookup('showcase_account', { multiple: true })`, seeded from an array of natural keys (`['Northwind', 'Contoso']`) so each element resolves independently to an account id. That makes the specimen complete and doubles as a boot-time regression guard, which is what field_zoo exists for: before the fix the array was rejected as a non-string reference and the field vanished from the row, so the gallery shipped silently missing one relational type. The multi-value USER field (`f_users`) stays unseeded, now with the reason recorded on the object: `sys_user` rows come from SIGN-UP, not seeds (see security/seed-approval-demo.ts), so on a fresh boot no human user exists for a natural key to resolve against. Authoring one would make the whole showcase seed load report success: false on every first boot. The multi-value reference mechanics the two fields share are covered by `f_lookups`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gusro3gdGv4wgbBnaFy9ah
1 parent ac65bc5 commit ca0a1f8

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

examples/app-showcase/src/data/objects/field-zoo.object.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,22 @@ export const FieldZoo = ObjectSchema.create({
9999

100100
// ── Relational ───────────────────────────────────────────────────────
101101
f_lookup: Field.lookup('showcase_account', { label: 'Lookup → Account' }),
102+
// Multi-value reference — stores an ARRAY of account ids (JSON column).
103+
// Seeded from an array of natural keys, one per element (framework#3911);
104+
// this is the seedable half of the `multiple: true` reference surface —
105+
// see `f_users` below for the half that a fresh boot cannot seed.
106+
f_lookups: Field.lookup('showcase_account', { label: 'Lookup → Accounts (multiple)', multiple: true }),
102107
f_master_detail: Field.masterDetail('showcase_project', { label: 'Master-Detail → Project' }),
103108
f_tree: { type: 'tree', label: 'Tree (self/category)', reference: 'showcase_category' },
104109

105110
// ── User (lookup specialized to sys_user) ────────────────────────────
111+
// NOT seeded, and deliberately so: `sys_user` rows are created by SIGN-UP,
112+
// not by seeds (see security/seed-approval-demo.ts — "users can't be
113+
// seeded (they sign up)"), so on a fresh boot there is no human user for a
114+
// natural key to resolve against. Authoring one here would make the whole
115+
// showcase seed load report `success: false` on every first boot. The
116+
// multi-value REFERENCE mechanics these fields share are demonstrated by
117+
// `f_lookups` above; assign these two in the UI once you have signed up.
106118
f_user: Field.user({ label: 'User → sys_user (single)' }),
107119
f_users: Field.user({ label: 'Users (multiple)', multiple: true }),
108120
f_owner: Field.user({ label: 'Owner (current_user default)', defaultValue: 'current_user' }),

examples/app-showcase/src/data/seed/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ const memberships = defineSeed(ProjectMembership, {
256256
// Relational/computed fields (lookup/master_detail/tree/record-map, formula/
257257
// summary/autonumber) resolve or generate at runtime. `f_master_detail` is the
258258
// owning Project; `f_lookup` the Account — referenced by their seed externalId.
259+
//
260+
// `f_lookups` is the MULTI-VALUE reference case (framework#3911): a
261+
// `multiple: true` lookup stores an array of ids, so the seed value is an
262+
// ARRAY of natural keys and each element resolves independently. It is also
263+
// the regression guard for that resolution — before the fix the array was
264+
// rejected as a non-string reference and the field vanished from the row,
265+
// leaving the specimen silently missing one relational type.
266+
// The multi-value USER field (`f_users`) stays unseeded on purpose: sys_user
267+
// rows come from sign-up, not seeds — see the note on the object.
259268
const fieldZoo = defineSeed(FieldZoo, {
260269
mode: 'upsert',
261270
externalId: 'name',
@@ -272,7 +281,7 @@ const fieldZoo = defineSeed(FieldZoo, {
272281
f_date: '2026-06-17', f_datetime: '2026-06-17T14:30:00Z', f_time: '14:30',
273282
f_boolean: true, f_toggle: true,
274283
f_select: 'high', f_multiselect: ['red', 'green'], f_radio: 'yes', f_checkboxes: ['email', 'push'], f_tags: ['alpha', 'beta'],
275-
f_lookup: 'Northwind', f_master_detail: 'Website Relaunch',
284+
f_lookup: 'Northwind', f_lookups: ['Northwind', 'Contoso'], f_master_detail: 'Website Relaunch',
276285
f_location: { lat: 47.6062, lng: -122.3321 }, f_address: { street: '1 Main St', city: 'Seattle', state: 'WA', postal_code: '98101', country: 'US' },
277286
f_code: '{\n "ok": true\n}', f_json: { nested: { k: 'v' }, list: [1, 2, 3] }, f_color: '#2563EB',
278287
f_rating: 4, f_slider: 60, f_progress: 80,

0 commit comments

Comments
 (0)