Skip to content

Commit e69fa46

Browse files
refactor(objectql): the engine sort door judges computed types by the spec's predicate (#37835)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DLCo5F2y7fgbM8tstGoyyUn)_ Fixes #37810 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:引擎内部调用(钩子、流程)排序时判断「计算字段不能排序」,改为与 HTTP 数据接口读同一个来源,今天的结果完全不变。 - 属于排序闸门统一来源的收尾,替上一张排序闸门卡把引擎这一侧补齐,并改掉六处仍提旧集合名的注释。 - 出错的话只会是某种字段类型的排序被误拒或误放,一条测试会立刻变红;改动可以直接撤回。 - 无。 ## What changes - **The engine door reads the one source.** `assertOrderByIsMaterializable` (`packages/objectql/src/engine-top-level.ts`) judged "computed on read" with its own `type === 'formula'`. It now asks `isVirtualSearchField` from `@objectstack/spec/data`, the predicate the Data API door (`assertSortFieldsExist`, third verdict) and the sortability projection already read. `SEARCH_VIRTUAL_TYPES` is pinned to exactly `formula`, and `isVirtualSearchField` is true exactly for a string `type` in that set, so no verdict moves for any field, schema-valid or not. Code, status, `field`, `fields` and message are unchanged. - **A pin holds the two doors together.** `packages/objectql/src/engine-sort-door-agreement.test.ts`: for every member of `FieldType.options` it asks the engine door and the Data API door about the same sort over the same definition, and fails if they part. It copies no verdict table. A companion field declaring `sortable: false` tells the Data API door's third verdict (computed type, names the field alone) from its fourth (names the companion), the same device as the metadata-protocol agreement test. The engine door does not judge `sortable: false`, so the companion never moves its answer. A control asserts the table has both refused and accepted types. - **The ledger of other sites now lives beside the engine door.** The docblock gains a "ONE SOURCE" paragraph and "THE OTHER SITES" list: `fieldHasColumn` and `SqlDriver.createColumn` (driver-sql), `remote-transport.ts` (driver-turso), `planFormulaProjection` and `search-companion.ts` (objectql), `VIRTUAL_FIELD_TYPES` (plugin-audit). None of those sites changes. - **Comments that named the retired set.** `packages/lint/src/validate-sortable-fields.ts` (two places; the first pointed at a note that no longer exists and now points at the two doors' "ONE SOURCE" notes), `packages/drivers/driver-sql/src/sql-driver-external-unprovisioned-sort-anchor.test.ts` (two places), and the two `ui/packages/plugin-list` tests. Comment-only. - **Changeset:** `@objectstack/objectql` patch. ## Read first 1. `packages/objectql/src/engine-top-level.ts`, the `assertOrderByIsMaterializable` hunk: the one-line predicate swap is the only behaviour edit in the PR. 2. `packages/objectql/src/engine-sort-door-agreement.test.ts`: how the Data API door's third verdict is told from its fourth. 3. `packages/lint/src/validate-sortable-fields.ts`: the rewritten pointer near the top of the docblock. ## Two-minute check `pnpm --filter @objectstack/objectql exec vitest run src/engine-sort-door-agreement.test.ts` prints `Tests 50 passed (50)` (one control plus 49 field types). ## Tests All runs at head `4edfb2fd99`, through `scripts/pm/os-verify-lock.sh`, after building the `@objectstack/objectql` dependency closure. <details><summary>Package suites and typecheck (all green)</summary> ``` pnpm --filter @objectstack/objectql test Test Files 639 passed (639) Tests 14485 passed (14485) pnpm --filter @objectstack/objectql typecheck check:test-typecheck: OK, the test layer compiles under packages/objectql/tsconfig.test.json (debt file unchanged) pnpm --filter @objectstack/lint typecheck check:test-typecheck: OK pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-external-unprovisioned-sort-anchor.test.ts Test Files 1 passed (1) Tests 12 passed (12) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Ablation: the pin goes red the day the spec's set grows without the engine door</summary> The future case, staged on disk: `SEARCH_VIRTUAL_TYPES` in `packages/spec/src/data/search-fields.ts` widened to `formula` and `summary` with `scripts/ablation-replace.mjs` (anchor 1 to 0, blob changed), spec rebuilt, and `scripts/ablation-dist-preflight.mjs` found the widened set in 2 built files of `packages/spec/dist`. (Its tree reading answered exit 3 only because the source spells the set with single quotes and the build with double quotes; the dist reading, the one the suite consumes, passed.) ``` Leg A engine door reads isVirtualSearchField, spec set widened -> Tests 50 passed (50) Leg B engine door back to its formula literal, spec set widened -> Tests 1 failed | 49 passed (50) FAIL a `summary` field: the engine door refuses it exactly when the Data API door calls it computed - "engineCallsComputed": true, + "engineCallsComputed": false, Leg C formula literal, spec restored and rebuilt (preflight: widened set absent from all 614 built files) -> 50 passed Leg D this PR as committed, today's spec -> 50 passed ``` So Leg B is the drift the card describes: the Data API door refuses `summary` and the engine door lets it through. Leg A shows the change ends it, and Leg C shows the two are identical today. After restoring, both source files matched their HEAD blobs, `git status --porcelain` was empty and `git diff HEAD` was empty. </details> ## Acceptance notes - **One comment outside the claimed surface still names `UNMATERIALIZED_SORT_TYPES`.** `packages/metadata-protocol/src/protocol-query-validation.ts` around line 613, in the Data API door's own "ONE SOURCE" note: "This door used to carry a set of its own for the same fact (`UNMATERIALIZED_SORT_TYPES`, `formula` alone, retired here)". It is a history pointer, kept on purpose so a search for the old name lands on its replacement (contract record 7209730357, N4). The card's acceptance line reads "no comment outside CHANGELOG files", and the card's own list names the six comments edited here. The file is not in the claim, so it is left as it is and raised in the report. The shipped changeset `.changeset/37386-sort-door-reads-projection-predicate.md` does not name the set. - **The refusal text still says "A formula field is virtual".** Unchanged on purpose: no verdict and no message moves, and `query-expression-conformance.test.ts` pins the wording across doors. The day `SEARCH_VIRTUAL_TYPES` grows, that sentence needs the type name too. Noted, not filed. - **The driver-sql anchor test still asserts `not.toBe('formula')`.** `driver-sql` depends on `@objectstack/spec`, so it could ask `isVirtualSearchField` instead. The claim makes that file comment-only, so it is left alone. Noted, not filed. - **The pin calls the door function, not `ObjectQL.find`.** That keeps it free of an engine boot for 49 types. `query-expression-conformance.test.ts` already pins the wiring from `engine.find` / `engine.findOne` to this door. - **The `ui/` comment edits run no local test.** Comment-only. `Test UI` covers them in CI. ## Verification - `node scripts/pm/dispatch-gates.mjs --commands` (76 families for this diff) run at `4edfb2fd99`: 73 exit 0. `--ran` reconciliation: 76 of 76 accounted for. - NOT MEASURED, prerequisite missing in this container (CI runs all three): `node scripts/check-plugin-teardown-shape.mjs --self-test` (exit 3, its pinned fixture commit is out of reach of a shallow clone); `pnpm check:dual-build-cjs-loads` (exit 3, PREREQUISITE NOT MET: 80 packages have no `dist/`); `pnpm --dir ui exec vitest run scripts/` (one red case, `unit-registry-absence-collision.test.ts`, because `@objectstack/client` has no `dist/` here, so the files that import it could not be measured; this diff touches no `ui/` module). - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: OK, 1 anchor judged, 0 lost. - `node scripts/pm/overlap-check.mjs`: clean against `origin/main` `9b50fedbfa` and the two open PRs that share `engine-top-level.ts` (#37676, #37366). - Dogfood: not run. The title has no `!` and there is no `(narrowing)` arm. --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cxBECSPtHxQMZDHSie)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent adb65d1 commit e69fa46

7 files changed

Lines changed: 184 additions & 23 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
refactor(objectql): the engine's own sort door judges a computed field type by the spec's predicate, as the Data API's door does
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`ObjectQL.find` and `ObjectQL.findOne` refuse an order by a field whose type is computed on read (`400 INVALID_SORT`), for callers that reach the engine directly, such as hooks and flows. The engine decided "computed on read" from a `formula` literal of its own. The Data API's sort door and the sortability projection served on `GET /meta/object/:name` decide it from `@objectstack/spec/data`'s `isVirtualSearchField`. The engine door now reads that predicate too.
11+
12+
Nothing changes for a caller: the spec's set holds `formula` and nothing else, so every sort is accepted or refused as before, with the same code, status and message. What changes is what happens when a computed type is added to the spec's `SEARCH_VIRTUAL_TYPES`: an in-process `find` is refused together with the Data API, instead of sending the order to a driver that has no column for it and returning the rows unsorted.
13+
14+
What to do: nothing.

‎packages/drivers/driver-sql/src/sql-driver-external-unprovisioned-sort-anchor.test.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444
//
4545
// - `assertSortFieldsExist` (`@objectstack/metadata-protocol`, `protocol.ts`,
4646
// #6994) — the REST ingress. Precedence `unknown` > `dotted` >
47-
// unmaterializable; the third verdict filters `UNMATERIALIZED_SORT_TYPES`,
48-
// which is `formula` alone. An injected anchor IS in `gate.known` (the
49-
// registry injected it into the served schema) and is undotted.
47+
// unmaterializable; the third verdict filters by `isVirtualSearchField`
48+
// (`@objectstack/spec/data`, `SEARCH_VIRTUAL_TYPES`), which is `formula`
49+
// alone. An injected anchor IS in `gate.known` (the registry injected it
50+
// into the served schema) and is undotted.
5051
// - `assertOrderByIsMaterializable` (`@objectstack/objectql`, `engine.ts`,
5152
// #7095) — the engine's own boundary, for callers that never pass ingress:
52-
// `schema.fields[f]?.type === 'formula'`, the same narrowing.
53+
// the same `isVirtualSearchField`, the same narrowing.
5354
//
5455
// Both live in packages that sit ABOVE this one in the dependency graph
5556
// (`driver-sql` depends on `spec`/`core`/`types` only), so this file cannot
@@ -255,9 +256,10 @@ describe('SORT over an unprovisioned injected anchor on a federated object (prem
255256

256257
it("ANCHORS ARE NOT 'formula' — the type both SORT doors narrow on", () => {
257258
// Why both doors let this ORDER BY through, asserted from the spec's own
258-
// injected definitions. `UNMATERIALIZED_SORT_TYPES` (metadata-protocol) and
259-
// the engine's `=== 'formula'` are unreachable from this package; this is
260-
// the same fact from the side this package CAN see. If an anchor ever
259+
// injected definitions. The two doors (metadata-protocol's and the
260+
// engine's) are unreachable from this package, and both judge by
261+
// `isVirtualSearchField`, `formula` alone today; this is the same fact
262+
// from the side this package CAN see. If an anchor ever
261263
// becomes a `formula`, the doors refuse it and this file's premise is gone.
262264
for (const anchor of ANCHORS) {
263265
const type = String((ANCHOR_DEFS as any)[anchor]?.type ?? '');

‎packages/lint/src/validate-sortable-fields.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@
101101
* gating a sort with it would refuse the two types that sort CORRECTLY:
102102
* `summary` is a `table.float` maintained by the engine and `autonumber` a
103103
* `table.string` the engine assigns. The distinction is pinned by name in the
104-
* engine's own conformance suite and restated in `protocol.ts`'s
105-
* `UNMATERIALIZED_SORT_TYPES` note; widening here would produce the false
106-
* finding that makes authors stop trusting the linter (ADR-0072 D1).
104+
* engine's own conformance suite and restated at both runtime sort doors,
105+
* which read `isVirtualSearchField` too (the "ONE SOURCE" notes on
106+
* `assertSortFieldsExist`'s third verdict and `assertOrderByIsMaterializable`);
107+
* widening here would produce the false finding that makes authors stop
108+
* trusting the linter (ADR-0072 D1).
107109
*
108110
* ── Which sort positions are walked, and which were checked and are not ──
109111
*
@@ -214,11 +216,11 @@
214216
* carry since #8340.
215217
*
216218
* WHY THIS AXIS NEEDS ITS OWN AUTHORING ANSWER — neither runtime door refuses
217-
* it. Both key on `formula` ALONE (`UNMATERIALIZED_SORT_TYPES`): the ingress
218-
* gate's third verdict (`assertSortFieldsExist`, #6994) and the engine's
219-
* (`assertOrderByIsMaterializable`, #7095). An injected anchor is a `datetime`
220-
* or `lookup`, it IS in `gate.known` (the registry injected it into the served
221-
* schema), and it is undotted — so it passes all three verdicts and reaches
219+
* it. Both key on the computed type ALONE (`isVirtualSearchField`, `formula`
220+
* today): the ingress gate's third verdict (`assertSortFieldsExist`, #6994)
221+
* and the engine's (`assertOrderByIsMaterializable`, #7095). An injected
222+
* anchor is a `datetime` or `lookup`, it IS in `gate.known` (the registry
223+
* injected it into the served schema), and it is undotted — so it passes all three verdicts and reaches
222224
* the driver. Measured (#10474) with a real `SqlDriver` over better-sqlite3,
223225
* the object declared exactly as `examples/app-showcase` declares it, against
224226
* a remote `customers` table carrying `[id, name, email, region,
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The engine's own sort door and the Data API's sort door answer one question
5+
* — is this field's TYPE computed on read, with no column to order by — from
6+
* one source, `isVirtualSearchField` (`@objectstack/spec/data`).
7+
*
8+
* - The engine door, `assertOrderByIsMaterializable`, guards a caller that
9+
* reaches `ObjectQL.find` / `findOne` directly (a hook, a flow).
10+
* - The Data API door, `assertSortFieldsExist`'s third verdict
11+
* (`@objectstack/metadata-protocol`), guards everything reaching `findData`.
12+
*
13+
* The engine door used to test a `'formula'` literal of its own while the
14+
* Data API door read the spec's set. Both held `formula` alone, so they agreed
15+
* only while the spec's set did not grow. The day it grows without the engine,
16+
* the Data API refuses the new type and an in-process `find` sends the ORDER BY
17+
* to a driver with no column for it, which drops the sort and answers success.
18+
*
19+
* So this file copies no verdict table. For EVERY member of the spec's
20+
* `FieldType` it asks both doors and holds them to each other. It tells the
21+
* Data API door's third verdict from its fourth (an author's
22+
* `sortable: false`, read through the projection) without reading a sentence:
23+
* the sort names the field under test AND a companion that declares
24+
* `sortable: false`, and the third verdict names the computed field alone,
25+
* where the fourth names the companion. The engine door does not judge
26+
* `sortable: false` at all, so the companion never moves its answer.
27+
*/
28+
29+
import { describe, it, expect, vi } from 'vitest';
30+
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
31+
import { FieldType } from '@objectstack/spec/data';
32+
import { assertOrderByIsMaterializable } from './engine-top-level.js';
33+
34+
const OBJECT = 'engine_sort_agreement';
35+
36+
/** Every field type the spec knows, as the enum lists them. */
37+
const FIELD_TYPES: readonly string[] = FieldType.options;
38+
39+
const fieldOf = (type: string) => `f_${type}`;
40+
41+
/** A stored column whose author declared it unsortable: the Data API door's fourth verdict, by construction. */
42+
const COMPANION = 'declared_unsortable';
43+
44+
const DEFINITION = {
45+
name: OBJECT,
46+
fields: {
47+
...Object.fromEntries(FIELD_TYPES.map((type) => [fieldOf(type), { name: fieldOf(type), type }])),
48+
[COMPANION]: { name: COMPANION, type: 'text', sortable: false },
49+
},
50+
};
51+
52+
const orderByOf = (type: string) => [
53+
{ field: fieldOf(type), order: 'asc' as const },
54+
{ field: COMPANION, order: 'asc' as const },
55+
];
56+
57+
type Refusal = { code?: unknown; status?: unknown; field?: unknown; fields?: unknown };
58+
const envelopeOf = (err: unknown) => {
59+
const r = err as Refusal;
60+
return { code: r.code, status: r.status, field: r.field, fields: r.fields };
61+
};
62+
63+
/** The engine door's answer: the refusal it threw, or null when it lets the sort through. */
64+
function engineDoor(type: string) {
65+
try {
66+
assertOrderByIsMaterializable(OBJECT, 'find', DEFINITION, orderByOf(type));
67+
} catch (err) {
68+
return envelopeOf(err);
69+
}
70+
return null;
71+
}
72+
73+
/** The Data API door's answer to the same sort, over the same definition. */
74+
async function dataApiDoor(type: string) {
75+
const find = vi.fn(async () => []);
76+
const engine = { registry: { getObject: (name: string) => (name === OBJECT ? DEFINITION : undefined) }, find };
77+
const protocol = new ObjectStackProtocolImplementation(engine as any);
78+
try {
79+
await protocol.findData({ object: OBJECT, query: { orderBy: orderByOf(type) } });
80+
} catch (err) {
81+
return envelopeOf(err);
82+
}
83+
return null;
84+
}
85+
86+
/** The computed-type verdict, as an envelope: what both doors answer for a computed field. */
87+
const computedVerdict = (type: string) => ({
88+
code: 'INVALID_SORT', status: 400, field: fieldOf(type), fields: [fieldOf(type)],
89+
});
90+
91+
const engineCallsComputed = (type: string) => engineDoor(type) !== null;
92+
93+
describe('the engine sort door and the Data API sort door agree on which field types are computed', () => {
94+
it('the table is not empty on either side: the engine door refuses some types and lets others through', () => {
95+
// Without both, every row below would agree about nothing.
96+
expect(FIELD_TYPES.filter(engineCallsComputed), 'field types the engine door refuses').not.toEqual([]);
97+
expect(FIELD_TYPES.filter((type) => !engineCallsComputed(type)), 'field types the engine door lets through')
98+
.not.toEqual([]);
99+
});
100+
101+
it.each(FIELD_TYPES)('a `%s` field: the engine door refuses it exactly when the Data API door calls it computed', async (type) => {
102+
const engine = engineDoor(type);
103+
const dataApi = await dataApiDoor(type);
104+
// The Data API door always refuses this sort (the companion is unsortable);
105+
// the verdict that fires says which side of the question the type is on.
106+
const dataApiCallsComputed = JSON.stringify(dataApi?.fields) === JSON.stringify([fieldOf(type)]);
107+
expect({ type, engineCallsComputed: engine !== null }).toEqual({ type, engineCallsComputed: dataApiCallsComputed });
108+
if (dataApiCallsComputed) {
109+
// One wire envelope on both doors for the one condition.
110+
expect(engine).toEqual(computedVerdict(type));
111+
expect(dataApi).toEqual(computedVerdict(type));
112+
} else {
113+
// CONTROL: the Data API refused for the companion, by its fourth verdict.
114+
expect(dataApi).toEqual({ code: 'INVALID_SORT', status: 400, field: COMPANION, fields: [COMPANION] });
115+
}
116+
});
117+
});

‎packages/objectql/src/engine-top-level.ts‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// re-exports, by name, every declaration here it exported before, so every
1212
// importer of `./engine.js` reads what it read.
1313

14-
import { AUDIT_PROVENANCE_FIELDS, ENGINE_UPDATE_UPSERT_REMOVED, FILE_REFERENCE_TYPES, FullTextSearchSchema, QUERY_CURSOR_REMOVED, QUERY_DISTINCT_REMOVED, REFERENCE_VALUE_TYPES, RPC_QUERY_ALIAS_SLOTS, VALID_AST_OPERATORS, foldQueryAliasSlots, isFilterAST, isMultiValueField, lowerFilterCondition, normalizeFilterComparandTypes, parseFilterAST, percentScaleOf, readAutonumberCounter, referenceCarrierOf, referenceTargetOf, resolveInjectedColumnProvenance } from '@objectstack/spec/data';
14+
import { AUDIT_PROVENANCE_FIELDS, ENGINE_UPDATE_UPSERT_REMOVED, FILE_REFERENCE_TYPES, FullTextSearchSchema, QUERY_CURSOR_REMOVED, QUERY_DISTINCT_REMOVED, REFERENCE_VALUE_TYPES, RPC_QUERY_ALIAS_SLOTS, VALID_AST_OPERATORS, foldQueryAliasSlots, isFilterAST, isMultiValueField, isVirtualSearchField, lowerFilterCondition, normalizeFilterComparandTypes, parseFilterAST, percentScaleOf, readAutonumberCounter, referenceCarrierOf, referenceTargetOf, resolveInjectedColumnProvenance } from '@objectstack/spec/data';
1515
import type { DroppedFieldsEvent, FilterCondition, FilterLoweringOptions, HookContext, QueryAST, QueryAliasSlot, RecycleBinClearedReference, ServiceObject } from '@objectstack/spec/data';
1616
import type { EngineFilterJudgement, ISecurityService } from '@objectstack/spec/contracts';
1717
import { assertFilterIsMaterializable, assertListComparandShapes, collectComposableReadableIds, invalidFilterError } from './filter-comparand-shape.js';
@@ -1861,6 +1861,32 @@ function withFileOwnerKey(
18611861
* a dotted PROJECTION entry is refused since #7589 —
18621862
* {@link assertProjectionHasNoDottedPaths}, directly below.
18631863
*
1864+
* ONE SOURCE — "computed on read" is judged by `isVirtualSearchField`
1865+
* (`@objectstack/spec/data`, set `SEARCH_VIRTUAL_TYPES`), the predicate the
1866+
* Data API's sort door (`assertSortFieldsExist`, metadata-protocol) and the
1867+
* served sortability projection (`resolveObjectSortability`, `virtual-type`)
1868+
* read too, never a type literal of this door's own. A type added to the
1869+
* spec's set is then refused here and at the Data API together; a literal
1870+
* here would let an in-process `find` drop the sort the Data API refuses.
1871+
* `engine-sort-door-agreement.test.ts` holds the two doors together for
1872+
* every `FieldType`. It is the STORAGE fact, deliberately not the spec's
1873+
* `COMPUTED_VALUE_TYPES` (the write contract): `summary` and `autonumber`
1874+
* have stored columns and sort.
1875+
*
1876+
* THE OTHER SITES that spell the same fact with a `formula` literal of their
1877+
* own, read from the predicate by none of them yet. This list is their
1878+
* ledger (it moved here when the Data API door's local set was retired);
1879+
* changing one of them is its own card, and a type added to the spec's set
1880+
* needs each of them reworked first:
1881+
* - `driver-sql`: `fieldHasColumn` (`schema-drift.ts`) and
1882+
* `SqlDriver.createColumn` (`sql-driver.ts`), the DDL that gives a
1883+
* `formula` no column;
1884+
* - `driver-turso`: `remote-transport.ts`, which skips it with the same
1885+
* "Virtual — no column" note;
1886+
* - this package: {@link planFormulaProjection} above and
1887+
* `search-companion.ts`'s title-eligibility check;
1888+
* - `plugin-audit`: `VIRTUAL_FIELD_TYPES` (`audit-writers.ts`).
1889+
*
18641890
* A registry-less host (`schema` undefined) returns early, exactly as the
18651891
* ingress gate returns early when `resolveQueryFields` cannot answer: a door
18661892
* that cannot see the field map must not invent a verdict about it.
@@ -1876,7 +1902,7 @@ function assertOrderByIsMaterializable(
18761902
const names = orderBy.map((node) =>
18771903
typeof node === 'string' ? node : String((node as any)?.field ?? ''));
18781904
const unmaterialized = names.filter((f) =>
1879-
f !== '' && !f.includes('.') && (schema.fields as any)[f]?.type === 'formula');
1905+
f !== '' && !f.includes('.') && isVirtualSearchField((schema.fields as any)[f]));
18801906
if (unmaterialized.length === 0) return;
18811907
const first = unmaterialized[0];
18821908
const type = String((schema.fields as any)[first]?.type);

‎ui/packages/plugin-list/src/__tests__/ListView.relationalSort.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ describe('ListView sort picker — relational fields (objectui#3096)', () => {
105105
* objectui#4294 — the remedy the hint names has to be one the server will
106106
* actually sort by. It used to say "add a formula field holding it", and a
107107
* formula field is precisely the type the server refuses to order by
108-
* (objectstack `UNMATERIALIZED_SORT_TYPES`, a hard 400 since
109-
* objectstack#6994): an author who followed the hint landed on a refusal —
108+
* (objectstack's sort doors judge it by `isVirtualSearchField` from
109+
* `@objectstack/spec/data`, a hard 400 since objectstack#6994): an author who followed the hint landed on a refusal —
110110
* and, since #4243 withheld formula fields from the picker, on a field this
111111
* very panel does not offer. The wording now tracks the server's own
112112
* refusal-door hint (a STORED, denormalised field, written when the source

‎ui/packages/plugin-list/src/__tests__/ListView.sortFieldFallback.test.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ describe('objectui#4243 part 1 — the sort picker no longer reuses `filterableF
184184
// deciding this: before the fix the unwhitelisted set already contained
185185
// every field, and `Total Amount` was offered here.
186186
//
187-
// objectstack `packages/metadata-protocol/src/protocol.ts`
188-
// `UNMATERIALIZED_SORT_TYPES` — a formula value is computed on read, no
189-
// driver materialises a column for it, and since objectstack#6994 a sort
190-
// naming one is a hard 400.
187+
// objectstack's sort doors (`assertSortFieldsExist`, judged by
188+
// `isVirtualSearchField` from `@objectstack/spec/data`) — a formula value
189+
// is computed on read, no driver materialises a column for it, and since
190+
// objectstack#6994 a sort naming one is a hard 400.
191191
await renderList({ sort: [{ field: 'name', order: 'asc' }] });
192192
await openSortPanel();
193193

0 commit comments

Comments
 (0)