You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b57f778
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-grid): leave a raw aggregate over a record-mode quantity out of the whole-set footer and group headers (#36271)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP3RHGWUG7UH3fNa4tBa9UC)_Fixes#36082
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
列表和表格分页时,底部合计行不再把「按行单位的数量」(一行千克、一行磅)的求和、平均、最小、最大放进整表合计查询;该列只显示计数,其他列照常显示整个视图的合计。
- 属于「数量带单位」上线前的收尾:引擎已拒绝不按单位分组的这类求和,不做这一步,整条合计查询被拒,其他列会悄悄退回成本页合计。
- 出错的话,影响的只是表格底部和分组标题里的数字;可直接撤回本改动,不涉及数据。
- 无。
## What changes
One rule in `recordCurrencyAggregates.ts`, two readers: a raw `sum` /
`avg` / `min` / `max` over a measure whose unit each record names itself
needs the rows grouped by that unit's field.
- `recordUnitField(def)` reads a `record`-mode quantity exactly as the
engine door `recordUnitFieldOf` does
(`packages/objectql/src/record-unit-aggregate-door.ts`): a `number` with
`unitConfig.unitMode === 'record'` and a non-empty `unitField`.
- `recordMeasureUnitField(def)` = the currency code field
(`recordCurrencyField` from `@object-ui/i18n`, unchanged) or that unit
field.
- `requiredCurrencyGrouping` becomes `requiredAggregateGrouping` and
`isMoneyAggregate` becomes `isMeasureAggregate` (module-internal, not in
the package barrel); the aggregate set stays one constant.
- Readers, all through that one helper: `wholeSetSummaryNodes` (the
whole-set footer query leaves the node out), `honestGroupAggregations`
(a group aggregate stands only when grouped by the unit field),
`useScopedColumnSummary` (the footer cell draws nothing for it, as for a
record-mode amount) and `offeredColumnSummaries` (the footer menu offers
the count family only).
- No engine, no `packages/spec` change. No new per-unit total.
## Tests
- `recordCurrencyAggregates-27188.test.tsx`, new top-level describe for
the quantity: footer draws no sum / avg / min / max and the count
stands; fixed-mode and plain-number controls sum; the menu offers no
aggregate; group aggregates stand grouped by `unit_code` and drop
otherwise; the predicate's edges (empty `unitField`, non-`number` type).
- `footerSummaryScope-12081.test.tsx`, new top-level describe (the
double now refuses a record-mode quantity aggregate as the engine does):
a view with a record-mode quantity `sum` beside a plain-number `sum`
sends one query carrying only `count` and `sum_amount`, the plain column
shows its whole-set figure, the quantity column shows nothing, zero
refusals. Control: a `fixed`-mode quantity is asked and totals over the
whole set.
- Ablations (one per leg, each through `scripts/ablation-replace.mjs`,
mutation landed and restore proven by blob hash): see Verification.
## Acceptance notes
- Group headers at a shallower depth (out of scope, for the seat):
`honestGroupAggregations` keeps a measure aggregate when the unit or
code field is at ANY grouping level, and `useServerGrouping` asks each
depth with the first `depth` grouping fields. Measured with the spec's
`compileListViewGroupQuery`: grouping `region` then `unit_code` with a
`sum` over `qty` compiles depth 1 to `groupBy: ["region"]` carrying
`sum_qty`, which the engine's unit door (and the currency door, for a
record-mode amount) refuses. This PR keeps the currency precedent's rule
unchanged and applies it to quantities, as the card ordered.
- The shared test files were extended instead of a new card-named file:
the root rule puts a new pin for a component with a shared harness file
into that file as a top-level describe.
## Verification
Read first:
1. `ui/packages/plugin-grid/src/recordCurrencyAggregates.ts`:
`recordUnitField` must match the engine door's reading.
2. `ui/packages/plugin-grid/src/useWholeSetSummary.ts`: the leave-out
line in `wholeSetSummaryNodes`.
3. `ui/packages/plugin-grid/src/useColumnSummary.ts`: the footer skip
and `offeredColumnSummaries`.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/recordCurrencyAggregates-27188.test.tsx
packages/plugin-grid/src/__tests__/footerSummaryScope-12081.test.tsx`
from the repo root; expect 42 passed.
Readings (source tree at 9f56bc1; the test runs were taken at
ae56a75, whose sources are byte-identical, the later commit adds only
the changeset):
<details><summary>Pin files and the plugin-grid suite</summary>
- `vitest run` of the two pin files: Test Files 2 passed (2), Tests 42
passed (42).
- `vitest run packages/plugin-grid/`: Test Files 300 passed (300), Tests
2657 passed (2657); lock VERDICT command-exit 0.
- `pnpm --filter @object-ui/plugin-grid type-check` (tsc on src and on
`tsconfig.test.json`, which lists both pin files): VERDICT command-exit
0.
</details>
<details><summary>Ablations, one per leg</summary>
Each mutation through `scripts/ablation-replace.mjs` (anchor 1 to 0,
blob changed), restored with blob equal to HEAD and an empty `git diff
HEAD`. The subject resolves to `src` (relative imports), so no rebuild
sits between mutation and run.
- Shared predicate (`?? recordUnitField(def)` removed): 5 failed / 37
passed, exactly the five quantity pins; every currency pin and control
stays green. A first attempt was refused by the tool (the replacement
was a bare semicolon, whose count could not rise); it ran nothing and is
not counted.
- Whole-set leave-out (the `continue` in `wholeSetSummaryNodes`
removed): 5 failed / 25 passed, the four record-currency pins and the
quantity whole-set pin.
- Footer cell skip disabled: 5 failed / 37 passed, the two footer pins
(amount, quantity) and the three whole-set pins (two currency, one
quantity): the left-out column falls back to a page sum over mixed
units.
- Footer menu (`offeredColumnSummaries`) disabled: 1 failed / 11 passed,
the quantity menu pin.
- Group filter (`honestGroupAggregations` keeps all): 2 failed / 10
passed, the currency and the quantity drop pins.
</details>
<details><summary>Local gate subset</summary>
Derived by `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` (38 commands); all 38 exit 0. `pnpm --dir ui
exec vitest run scripts/` queue-timed out twice on the shared verify
lock (exit 99), then passed on the third attempt after the PR was
opened: 172 files passed, 2 skipped; 5122 tests passed. `pnpm
check:type-check-debt` first queue-timed out, then exit 0 on retry.
Outside the list: `check-platform-checklist --changed-from origin/main`
exit 0 (no anchored file), `pnpm --dir ui check:new-line-citations` 0
new. `overlap-check` VERDICT clean.
</details>
<!-- signed: repo:objectstack#4 · os-project-manager ·
session_01FEkQ5okniknzVVR3KTSVr1 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-grid): leave a raw aggregate over a record-mode quantity out of the whole-set footer and the group headers
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The engine refuses a `sum` / `avg` / `min` / `max` over a `number` field declaring `unitConfig: { unitMode: 'record', unitField }` unless the query groups by `unitField` (ADR-0158 U7 R1): quantities in different units do not add. The grid now treats such a quantity the way it treats a `record`-mode currency amount (ADR-0144 D6), through one rule:
11
+
12
+
- The whole-set footer query of a paged list or grid leaves that column's aggregate out, so the other summarised columns keep their whole-set figures instead of all falling back to the current page's.
13
+
- The footer draws no `sum` / `avg` / `min` / `max` for that column, and its menu offers the count family only; the counts stand.
14
+
- A group-header aggregate over it stands only when the grid is grouped by its `unitField`.
15
+
16
+
A `fixed`-mode quantity and a `number` with no `unitConfig` total as before.
0 commit comments