Repository navigation
Commit eed422e
fix(core): drill a relationship path as one nested-relation condition, pushed down by the server (#35423)
Fixes #34990
Part of #35447
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #35481
## 维护者速读
1.
用户能看到什么变化:仪表盘和报表里按"关联对象的字段"(例如按客户的负责人)分组时,点开明细抽屉会直接列出对应记录,不再因为关联记录超过两百条而提示"太多,无法列出";但这类明细抽屉里暂不再提供"在列表中打开"按钮。
2.
为什么做:收口上一张"按关联字段钻取明细"修复里由席位批准的临时方案——原来由浏览器先读出关联记录再筛选,现在交给服务器在数据库里一次关联查询完成。
3.
出错会怎样:看板和报表的用户点开按关联字段分组的明细时会看到"记录加载失败"的提示,不会看到错误的数据;直接回滚本次改动即可恢复原来的行为。
4. 要你做什么:无,席位落地。
> **Declaration corrected (L1-a ACCEPT 7005070933):**
`convertFiltersToAST` is a published export of `@object-ui/core` and now
accepts the nested-relation map it used to refuse, so this PR is
`Clause-②: yes (widening)` (was `no`). `Metadata-protocol: none` and the
`patch` level stand. The changeset carries the same line from
`a7203afa`.
> **L2 S1 folded in (seat pick, contract review 7005257036; card #35447,
claimed on its thread 7006104820):** from `def1213f`,
`ValueDataSource`'s AST matcher refuses a nested-relation comparand (a
non-empty object with no `$` key) for every operator that reads it, with
the object arm's sentence through one shared builder
(`nestedRelationRefusalReason`). Before, `=` matched no row silently and
`!=` matched every row. Pin: new top-level describe in
`ValueDataSource.astFilterVocabulary.test.ts` (AST and object forms
refused alike, `!=` refused, CONTROL scalar `=`). The `data-objectstack`
README lowering table gains the node's row (its example runs in
`readme-filter-operator-table.test.ts`).
> **Declared as a narrowing (delta contract review 7006192304, M1;
changeset from `694b6011`):** the refusal turns a no-`$` object
comparand under `!=`, `not_contains` and the ordering operators from
serving every or some rows into a named refusal on the published
`ValueDataSource#find`. The changeset carries the BREAKING paragraph
(FROM / TO) and the ADR-0087 marker `not-required
(no-migration-prescription)`: the spec's comparand door already refuses
that comparand and no saved view filter can hold it. `patch` stays
(non-protocol). Full dogfood on `694b6011`: 482 passed, 3 skipped files,
0 failures. `Skills-docs:` follow-up #35481 is the drill drawer's "Open
in list" link, which this PR drops for a relationship-path dimension;
the narrowing itself is taught by no skill.
> **Narrowing contract review S2 folded in (from `b950ae60`):** the AST
arm treats a comparand as a nested-relation condition only when it is a
PLAIN object (prototype `Object.prototype` or `null`) with no `$` key,
so a class instance with its own keys (a moment / luxon date, a decimal)
compares through `valueOf` again under the ordering operators. Pins:
`not_contains` and `>` refusal legs beside `=` / `!=`; CONTROL legs for
a class instance under `>` and `<` and a `Date` under `>` (ablation of
the prototype check turns the two class-instance legs red). The
changeset now names the exact refused population instead of "refuses
anything else". Full dogfood on `b950ae60`: 482 passed / 3 skipped
files, 4092 tests, 0 failures (os-dev-report 7011424436).
## What changes
- **Client filter grammar: the nested-relation node.**
`convertFiltersToAST` (`@object-ui/core`) now lowers the nested-relation
form the spec already declares on `FilterCondition` (form 4: `{ account:
{ owner: 'u1' } }`, a plain object with no `$` key beneath a field) to
one equality node, `['account', '=', { owner: 'u1' }]`. The spec's
`parseFilterAST` reads that node back as the same nested condition,
which the server serves. It used to refuse the shape as an unknown
operator. The recognised population is the engine's own
`isNoOperatorObject` (no `$` key), so client and server name one shape;
a map that mixes `$` operators with plain keys is still refused. Nothing
on the client judges the inner condition: whether the field is a
relationship is decided by the server, which refuses anything else with
`INVALID_FILTER` / 400. The engine-internal semi-join leaf (ADR-0139 /
ADR-0155) is never spelled.
- **`resolveDatasetDrillFilter`: the two-step is removed.** A
relationship-path dimension (`account.owner`, up to ADR-0071's three
hops) now drills as one nested condition, one level per hop (`{ account:
{ parent: { kind: VALUE } } }`), instead of reading up to 200 related
ids per hop and filtering on `$in` them. No related record is read and
nothing is capped. Unchanged: the per-hop schema read that confirms each
hop is a single-valued relationship, the hop limit, the empty-bucket
refusal, and the plain-dimension-on-the-relationship-field case (it
becomes an `id` key inside the nested condition).
- **The PD5 exception docblock is retired** (seat ruling 6961225798,
bounded exception (a) whose exit is this node): the "resolved here
because the grammar has no nested-relation node yet" paragraph and the
"read in two steps" section are replaced by the nested-condition
description.
- `DATASET_DRILL_RELATED_ID_CAP` and the `too-many` member of
`DatasetDrillResolution` are no longer produced. They stay exported,
marked `@deprecated`, because removing them is a narrowing of
`@object-ui/core`'s published surface and their consumers (the drawer's
`too-many` notice and its locale strings) sit outside this claim's file
surface (see Acceptance notes).
## Tests
At head `0ff1d0ab` (origin/main `0967cbe6` merged; the incoming commits
touch none of the packages below). `dba9da83` adds one comment-only
commit restoring the objectstack#17469 citation the plugin-detail pin
requires; `a7203afa` changes only the changeset's `Clause-②` line.
- `pnpm --filter @object-ui/core test`: Test Files 243 passed (243),
Tests 4482 passed, 27 skipped.
- `pnpm --filter @object-ui/core type-check`: exit 0. `pnpm --filter
@object-ui/plugin-dashboard --filter @object-ui/plugin-report
type-check`: exit 0.
- Focused, verbose: the four touched test files, Test Files 4 passed
(4), Tests 168 passed (168).
- New pins: `filter-converter.test.ts` gains a top-level `describe('the
nested-relation node (objectstack#34990)')` (lowering + spec round trip,
a deeper relation with inner operators, beside plain keys and under
`$or`, CONTROL mixed map refused with `INVALID_FILTER`/400 naming
`owner`/`account`, CONTROL operator map and empty map unchanged).
- Flipped legs of the #34968 pins (only those that asserted the
two-step): in `dataset-drill-relationship-path-34907.test.ts` the
1-hop/2-hop/id-cap/empty-`$in` legs became 1-, 2- and 3-hop
nested-condition legs with zero `find` calls, a drawer-lowering leg
(`convertFiltersToAST` + `parseFilterAST` round trip), the shared-hop
leg and a plain-dimension `id` leg; in `DatasetWidget.test.tsx` the
first leg and the `too-many` notice leg; in
`DatasetReportRenderer.test.tsx` the first leg. Hop-limit,
unknown/multi-valued relationship, empty bucket, CONTROL single-object
drill and builder refusal legs are unchanged.
<details><summary>Ablation (one per changed behaviour, each via
scripts/ablation-replace.mjs, restored blob == HEAD and git diff HEAD
empty)</summary>
- Converter node disabled (`if (isNestedRelationCondition(...))` to `if
(false && ...)`, anchor 1 to 0, blob 53704b0 to d69c22c6): 5 failed /
23 passed, each failure `Unknown filter operator
'owner'/'owner_id'/'parent'`; restored to 53704b0.
- Resolver's nested write replaced with `{ $in: [] }` (blob 8c33515 to
2783b612): 6 failed / 3 passed in the 34907 file; restored to 8c33515.
Both suites import the module under test from source by relative path,
so no dist leg applies.
</details>
## Acceptance notes
- **"Open in list" is not offered for a relationship-path drill any
more.** `exactRecordListFilter` (app-shell) offers the escape hatch only
for a filter the list page's `filter[...]` URL dialect writes exactly;
that dialect has no spelling for a nested condition, so it answers
`null` and the drill stays in the drawer (code reading of its operator
loop, not a browser run). Under the two-step a drill with at most 200
related ids could escalate through `filter[account][in]`. Seat 5 picked
A (seat note on #34990): ship as is; the URL spelling is #35438.
- **Dead residue left by the fence:** the `too-many` arm in
`DatasetWidget.tsx` / `DatasetReportRenderer.tsx`, the `'too-many'`
entry of `DrillDownDrawer`'s notice table and its locale strings, plus
the deprecated exports above, are now unreachable. Removing them narrows
a published export; triage closed that card (#35439) as not planned at
first touch (7005794295): the removal rides the next major that narrows
`@object-ui/core` exports.
- The stale comment in
`ui/packages/data-objectstack/src/queryDataset.test.ts` ("resolved
through the related ids first") is corrected from `b950ae60`.
- Where the server cannot prove the subquery is the related read's own
statement (a related object with an object-scoped middleware or an
`afterFind` hook, another datasource, a federated object), it reads the
related ids itself under its 1,000 cap and refuses past it with
`INVALID_FILTER` / 400; the drawer then shows its localized load-failure
sentence. That is the server's documented behaviour, not a client bound.
## Verification
<details><summary>A1: the server takes the client's wire spelling and
pushes it down (SQLite, real engine, throwaway test, not
committed)</summary>
Real `ObjectQL` + `SqlDriver` (better-sqlite3) + `SecurityPlugin` +
`RestServer`, `GET /api/v1/data/:object` with `?filter=` set to the AST
JSON the client sends, knex query log captured:
- `['owner','=',{region:'NA'}]`: 200, ids d1, d3; 1 statement: select
from the ledger where owner in (select id from the owner table where
region = ? and the owner's row-scope predicate).
- `['ledger','=',{owner:{region:'NA'}}]` (two hops): 200, id n1; 1
statement with two nested in-subqueries, each carrying its object's row
scope.
-
`['and',['id','!=','zz'],['ledger','=',{title:'a',owner:{region:'NA'}}]]`:
200, id n1; 1 statement.
- CONTROL the old id form `['owner','in',['u1']]`: 200, ids d1, d3; 1
statement with a bound id list.
No statement reads related ids before the main read. A2: before this
change `convertFiltersToAST` refused the nested form (the converter
ablation above shows the refusal text). A3: 7 files, +207 / -128.
</details>
<details><summary>Gates</summary>
Local families: derived with `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` at `0ff1d0ab` (39
commands) and run in full; results are in the report comment on the
card. `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` before
each push. CI-owned families (lint, type-check programs, Test UI) are
read from this PR's check-runs.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB)_
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CajiB6BSQKWowy6YLB -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b68f9ae commit eed422e
11 files changed
Lines changed: 383 additions & 137 deletions
File tree
- .changeset
- ui/packages
- core/src
- adapters
- __tests__
- utils
- __tests__
- data-objectstack
- src
- plugin-dashboard/src/__tests__
- plugin-report/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
475 | 508 | | |
476 | 509 | | |
477 | 510 | | |
| |||
522 | 555 | | |
523 | 556 | | |
524 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
525 | 569 | | |
526 | 570 | | |
527 | 571 | | |
| |||
924 | 968 | | |
925 | 969 | | |
926 | 970 | | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
| 971 | + | |
933 | 972 | | |
934 | 973 | | |
935 | 974 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
0 commit comments