Follow-ups to #4701 (derived fields), lifted from the review of #4638 before it was closed in favor of #4701.
1. Enforce read-only on derived fields
Store.modifyRecords() currently ignores writes to a derived field, and a grid column bound to one is still editable - an inline edit appears to succeed and then vanishes. Proposed:
modifyRecords() throws when a modification names a derived field, e.g. Field 'notional' is derived and read-only - its value is computed at read time and cannot be modified.
Column.isEditableForRecord() returns false for a column whose field is derived, regardless of the column's editable config.
- Doc
FieldSpec.derivedFn accordingly (currently says writes are "ignored").
2. Close Store changedFields over dependsOn
#4701 (post catch-up) closes a producer's changedFields over dependsOn in View.dataOnlyUpdate, so a Cube tick naming only price still re-sums a derived notional. A plain Store has the same hole: updateData() with a StoreTransaction.changedFields hint naming only inputs is passed through to RecordSetDelta.changedFields, and GridTransactionManager.sortUnchanged() trusts it - a grid sorted on a derived column would not re-sort. Proposed: apply the same transitive closure in Store.updateData() before the hint reaches the RecordSet, and have the View reuse it (or a shared util) rather than keeping its own copy.
3. Guard canAggregateFn on level-derived CubeFields
CubeField throws on derivedFn + isDimension, but a level-derived field (no aggregator) that also sets canAggregateFn is accepted and the fn silently never runs. Throw at construction, as for isDimension.
4. Doc carry-overs
The FieldSpec.calculatedFn / Cube README prose from #4638 on read-by-name semantics (getters are not own properties, so never rely on own-property enumeration - use StoreRecord.getValues), keeping the fn pure and fast (it runs per cell paint and per sort comparison), and returning primitives or stable references so grid change detection can skip unchanged cells applies verbatim to derivedFn and should land in data/README.md / data/cube/README.md. The Cube README's WeightedAverageAggregator example should be replaced by the SUM/SUM/ratio decomposition (see #4747).
Follow-ups to #4701 (derived fields), lifted from the review of #4638 before it was closed in favor of #4701.
1. Enforce read-only on derived fields
Store.modifyRecords()currently ignores writes to a derived field, and a grid column bound to one is still editable - an inline edit appears to succeed and then vanishes. Proposed:modifyRecords()throws when a modification names a derived field, e.g.Field 'notional' is derived and read-only - its value is computed at read time and cannot be modified.Column.isEditableForRecord()returns false for a column whosefieldis derived, regardless of the column'seditableconfig.FieldSpec.derivedFnaccordingly (currently says writes are "ignored").2. Close
StorechangedFieldsoverdependsOn#4701 (post catch-up) closes a producer's
changedFieldsoverdependsOninView.dataOnlyUpdate, so a Cube tick naming onlypricestill re-sums a derivednotional. A plainStorehas the same hole:updateData()with aStoreTransaction.changedFieldshint naming only inputs is passed through toRecordSetDelta.changedFields, andGridTransactionManager.sortUnchanged()trusts it - a grid sorted on a derived column would not re-sort. Proposed: apply the same transitive closure inStore.updateData()before the hint reaches theRecordSet, and have the View reuse it (or a shared util) rather than keeping its own copy.3. Guard
canAggregateFnon level-derivedCubeFieldsCubeFieldthrows onderivedFn+isDimension, but a level-derived field (noaggregator) that also setscanAggregateFnis accepted and the fn silently never runs. Throw at construction, as forisDimension.4. Doc carry-overs
The
FieldSpec.calculatedFn/ Cube README prose from #4638 on read-by-name semantics (getters are not own properties, so never rely on own-property enumeration - useStoreRecord.getValues), keeping the fn pure and fast (it runs per cell paint and per sort comparison), and returning primitives or stable references so grid change detection can skip unchanged cells applies verbatim toderivedFnand should land indata/README.md/data/cube/README.md. The Cube README'sWeightedAverageAggregatorexample should be replaced by the SUM/SUM/ratio decomposition (see #4747).