Let a view be owned by a one-to-many view field

Closed
FE
2d ago
+1494-60

Adds view.ownerViewFieldId, a foreign key from a hidden TABLE_WIDGET view to the added one-to-many column it scopes. The scope view's filters and sorts decide which related records that column shows (e.g. "open action items, by due date"). The front end creates and edits it later in the stack through the existing view, view-filter and view-sort APIs.

Changes

  • Schema: view.ownerViewFieldId → viewField.id, ON DELETE CASCADE, DEFERRABLE INITIALLY DEFERRED, with a plain (non-unique) index. Deleting the column, its view or its field removes the scope view with its filters and sorts. Fast instance command 2.59.0_AddViewOwnerViewFieldIdFastInstanceCommand_1794591789191, fenced with @WasIntroducedInUpgrade; additive, no backfill.
  • Validation (cross-entity, on the post-migration state, so it sees view fields created in the same batch). A scope view must:
    • be a TABLE_WIDGET on the relation's target object;
    • be owned by a non-canonical view field of a one-to-many relation ("Only added columns can be scoped"), in the same application;
    • share visibility and creator with the view holding its owner column;
    • be the only scope view of that column. Enforced here rather than by a unique index, so an app can replace a scope view under a new identifier in one sync. The validator scans scope views once and counts them per owner column.
    • Scope views are re-checked when the view holding their owner column changes type, visibility or creator. An app sync cannot drop a column while still declaring its scope view.
  • Visibility and permissions: ViewService.createOne makes a scope view inherit visibility and creator from the owner column's view (the input transpiler and the complete-view upsert no longer take view maps for this), and it follows that view when its visibility changes. Creating one requires edit rights on that view. The create-view guard reads the owner only from the view input (GraphQL input, or the REST body).
  • Sync and export: preallocated ids in the create-view runner let a manifest create a column and its scope view in one sync. Export leaves out a scope view whose owner column is not exported.
  • Cache: deleting a view field, field or object also invalidates the view maps the cascade touches.
  • Public surface: View.ownerViewFieldId, CreateViewInput.ownerViewFieldId, ViewManifest.ownerViewFieldUniversalIdentifier (documented in layout/views.mdx). The owner cannot change after creation.

Stack

The work is split into short tracks that can be reviewed and merged in parallel. Each PR targets main or the one PR it builds on. Two PRs need several others; they target an integration branch (felix/relaxed-einstein-vxil3q-base-*, not a PR) that merges exactly their dependencies, so their diff shows only their own changes. A PR can merge once everything in its "Builds on" column is merged; retarget it to main at that point.

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.

TrackPRWhat it doesSizeCodeTests / generatedBuilds on
Server: views#30339Per-column settings on view fields (label, record limit)S+300 −2+703 −152main
Server: views#30341 👈A view can be owned by a one-to-many view field (scope view)M+584 −56+891 −4main
Server: views#30472Lookup: a view field shows one field of its related recordM+280 −38+428 −4#30339
Server: views#30466upsertViewFieldWithScope: save a column with its settings, lookup and scope in one migration (~600 lines moved out of view-widget-upsert)L+1330 −567+1117 −256#30339, #30341, #30472
Server: views#30450Expose column scopes and lookups in the view AI toolsS+31+222#30339, #30341, #30472
Server: query engine#30347Honor filter / orderBy / first on nested one-to-many relationsM+462 −86+509main
Server: query engine#30473One relation-selection tree through the common query layer (refactor, no behavior change)L+663 −685+277 −46#30347
Server: query engine#30465Each alias of a nested relation gets its own arguments and rowsL+595 −237+727 −21#30473
Front#30468Query a relation under an alias with its own filter, sort and limitS+140 −19—main
Front#30469Don't recreate a saved sort that comes back under a new idS+21 −17+8main
Front#30348Extra table columns and the Edit column panel, behind IS_COLUMN_SETTINGS_ENABLEDM+718 −76+152 −30#30339
Front#30349Scope one-to-many columns from the Edit column panelL+1053 −92+316 −18#30348, #30466, #30468, #30469, #30465
Front#30439Lookup columns in the table, editable from their cells (absorbs #30440)L+805 −223+283 −30#30349
Front#30458Lookup and scoped columns on boards and calendarsM+404 −284+140 −7#30439

The longest dependency chain is #30339 → #30348 → #30349 → #30439 → #30458; everything else is one or two levels deep. #30339, #30341 and #30472 each add a 2.59 instance command, so whichever merges after another may need a fresh timestamp.

Testing

  • Integration view-owner-view-field: create a scope view and remove it with its column or its column's view; recreate after soft delete; reject a wrong view type, wrong object, canonical column and non-relation column; reject a private scope view on a column the user cannot edit; reject turning a scope view into a regular view; inherit and follow the owner view's visibility.
  • Integration successful-sync-application-scope-view: column and scope view created in one sync; dropping a scoped column while keeping its scope view refused; mismatched visibility refused; scope view replaced under a new identifier in one sync.
  • Unit: create-view guard, manifest reconstruction, cache invalidation, registry and sort-order snapshots.

Generated by Claude Code