Technical guide
Technical guide

Rollups and name fields

The data engine now handles adaptive roll up fields as values with both manual and calculated states. A stored adaptive value contains isManual, manualValue, and calculatedValue. Queries return the effective scalar: the manual value when isManual is true, otherwise the calculated value. This also works for custom fields and joined field paths.

Recalculation

The engine recalculates parent rollups when relevant child records or dependent fields change, including quantity and unit price changes that affect a calculated line total. It supports COUNT, SUM, AVG, MIN, and MAX in the rollup summary path. Deleted child rows are excluded. With active children, an adaptive rollup enters calculated mode while preserving its previous manual value. When no child rows remain, it returns to manual mode and clears the calculated value. A manual value can be edited in manual mode; changing a calculated value through an ordinary record update is rejected.

The query engine extracts the effective value from adaptive JSON for ordinary and joined reads. The storage shape is an implementation detail; use object APIs and schema field names rather than writing the JSON directly. See core_engines/databaseSingleton.js, core_engines/queryContainer.js, and the adaptive rollup regression tests.

Record name fields

Object schemas can mark multiple fields as name fields, in addition to a canonical name field. Record lists and related lists pass this metadata to we-table, which links each marked name field to the record. Report tables also resolve direct and joined name fields to record links when an ID is available. lib/nameFieldHelper.js centralizes the name-field check; reports and lists still apply their own access and data rules.