Let a view field show one field of its related record

Merged
FE
3d ago
+0-0

Adds viewField.relationTargetFieldMetadataId so an added column on a many-to-one relation can show one field of the related record, e.g. Person → Company › Industry (a lookup column). Server side only; the front end follows in #30439.

Changes

  • Schema: nullable FK to fieldMetadata, ON DELETE CASCADE, partial index; mirrors viewFilter.relationTargetFieldMetadataId. Fast instance command 2.59.0_AddViewFieldRelationTargetFieldMetadataIdFastInstanceCommand_1794606690417.
  • Lifecycle: deleting or deactivating the target field removes the lookup column instead of leaving a dangling id. The update util resolves both foreign keys in one call.
  • Validation (view-field validator, create and update, using findFlatEntityByUniversalIdentifier): only on non-canonical columns of a many-to-one relation; the target must belong to the related object and must not be a relation (one hop).
  • Public surface: ViewField.relationTargetFieldMetadataId on the type and on the create, update and upsertViewFieldWithScope (#30466) inputs, so the Edit column panel saves a lookup column in one request; null on update clears it. Manifests carry it as relationTargetFieldMetadataUniversalIdentifier (documented in layout/views.mdx).
  • Every place that builds a view field sets the new property, including a type-only edit to the released 2-26 command. Client SDK and front metadata schema regenerated.

Stack

Merge top to bottom. Size counts changed lines outside tests and generated files: S < 300, M 300–800, L > 800. Sizes are a snapshot and are not kept in sync with every push.

#PRAreaWhat it doesSizeCodeTests / generated
1#30339serverPer-column settings on view fields (label, record limit)S+300 −2+703 −152
2#30341serverA view can be owned by a one-to-many view field (scope view)M+584 −56+892 −4
3#30347serverHonor filter / orderBy / first on nested one-to-many connectionsM+462 −86+509
4#30465serverEach alias of a nested relation gets its own arguments and rowsL+556 −273+665 −21
5#30348frontExtra table columns and the Edit column panelM+718 −76+152 −30
6#30466serverupsertViewFieldWithScope: save a column and its scope in one migration (~600 lines moved out of view-widget-upsert)L+1323 −567+1061 −256
7#30468frontQuery a relation under an alias with its own filter, sort and limitS+140 −19—
8#30469frontSave record filters and sorts to a given view (replaces the old hooks)M+341 −348—
9#30349frontScope one-to-many columns from the Edit column panelL+1053 −92+316 −18
10#30438 👈serverLookup: a view field shows one field of its related recordM+290 −39+476 −4
11#30439frontLookup columns in the tableL+712 −188+283 −30
12#30440frontEdit a looked-up field from its cellS+93 −35—
13#30458frontLookup and scoped columns on boards and calendarsM+404 −284+140 −7

Off the main line:

  • #30450 (server, S, code +31, tests +222): Expose lookup columns and column scopes in the view AI tools (branches off #30438)

Testing

  • Integration view-field-relation-target: accepted lookup on an added column; rejections (canonical column, non-relation, one-to-many, field of another object, relation target); column removed when the target field is deleted; saving and clearing a lookup through upsertViewFieldWithScope, and rejecting a relation target there.
  • Unit: validate-flat-view-field-relation-target, field deactivation side effects, manifest converters and snapshots.
  • view-owner-view-field, view-field-settings and upsert-view-field-with-scope integration specs pass. Server typecheck and lint.

View guided diff in cubic


Generated by Claude Code