Skip to content

Commit 8471b60

Browse files
committed
fix(core)!: changeset and stale drill comments for the flag and comparand edges
Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6bc4007 commit 8471b60

4 files changed

Lines changed: 57 additions & 15 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
'@object-ui/core': patch
3+
---
4+
5+
fix(core)!: a non-boolean `$null` / `$exists` flag is refused in the filter converter and the value data source, and so are the object comparands the value data source cannot compare
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. What moves is what convertFiltersToAST lowers and what ValueDataSource.find answers for filters the spec already refuses (a non-boolean $null / $exists flag, a plain object of another realm, a class instance under an equality, membership or text operator) or that this in-memory face cannot evaluate (a { $now, addDays } anchor): no stored row, registry key or authored value changes, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** for `convertFiltersToAST` and `ValueDataSource` (the in-memory `provider: 'value'` data source), for four filter shapes.
13+
14+
1. **A `$null` / `$exists` flag that is not a boolean**, such as `{ owner: { $null: 'no' } }`, `{ owner: { $exists: 1 } }` or `{ owner: { $null: { id: 'u1' } } }`.
15+
- FROM: the flag was read for its truthiness. `convertFiltersToAST` lowered `{ owner: { $null: 'no' } }` to `['owner', 'is_null', true]` and `{ owner: { $exists: 'no' } }` to `['owner', 'is_not_null', true]`, so a server-backed source answered the null-ness rows and its own door never saw the flag; the value data source answered the same rows (`'no'`, `1` and an object read as `true`; `0` and `null` as `false`).
16+
- TO: both refuse it, as they already refused a non-boolean `$empty` flag. The converter throws `FilterOperatorError` (`INVALID_FILTER` / 400) with `The '$null' filter operator on field 'owner' takes a boolean flag (true or false); received "no"`, and the value data source excludes every row and logs `filter operator '$null' on field 'owner' takes a boolean flag (true or false); received "no"`. `true` and `false` lower and match exactly as before. The spec's `FilterConditionSchema` and every query face already refused these flags.
17+
- The AST null-ness operators (`is_null`, `is_not_null` and their spellings) carry no flag and are not moved: direction comes from the operator name and the value slot is not read, as the spec's `parseFilterAST` reads it.
18+
2. **A plain object of another realm** (an iframe, a `vm` context), whose prototype is that realm's `Object.prototype`.
19+
- FROM: `convertFiltersToAST` read it as an operator map, so `{ age: foreignObject }` with `$gte: 18` lowered to `['age', '>=', 18]` and one with no `$` key lowered to the nested-relation node `['owner', '=', foreignObject]`, which the value data source compared by reference (`=` no row, `!=` every row).
20+
- TO: it is a comparand, as the spec's filter walk and the engine's `isNoOperatorObject` read it: the converter refuses it as the field's whole condition (`The filter on field 'age' carries a plain object from another realm in comparand position…`), and the value data source refuses it in comparand position under every operator (`filter comparand on field 'owner' is a plain object from another realm, which is neither a comparison value nor filter structure here`). The server refused it already.
21+
3. **A plain object with a `$` key that is not a `{ $field }` reference**, in comparand position on the value data source, the spec's `{ $now, addDays }` date anchor among them, such as `{ due: { $lt: { $now: true, addDays: 7 } } }`.
22+
- FROM: compared as a value: by reference, or as the text `[object Object]` (so `$lt` answered the rows sorting before that text, and `$ne` / `$nin` every row).
23+
- TO: refused under every operator that reads a comparand, whole or as a list member, in both dialects. The anchor gets `filter comparand on field 'due' is a { $now, addDays } date anchor, which the in-memory matcher does not resolve…`: the platform resolves it in the compared column's temporal form, and this source has no field types to read a form from, the reason it already refuses a `{ $field, addDays }` offset. Any other one gets `filter comparand on field 'owner' is an object carrying the key '$foo', which is neither a comparison value nor a { $field } reference`, the comparand the spec's door refuses. `convertFiltersToAST` still lowers the anchor verbatim for a server-backed source, which resolves it.
24+
4. **A class instance** (a moment or luxon date, a decimal object, a `RegExp`, a `Map`) as the comparand of an equality, membership or text operator on the value data source: `$eq`, `$ne`, an `$in` / `$nin` member, `$contains`, `$notContains`, `$startsWith`, `$endsWith`, and their AST spellings.
25+
- FROM: compared by reference or as its text: `$eq` and `$in` answered no row, `$ne`, `$nin` and `$notContains` every row.
26+
- TO: refused, in both dialects, with `filter comparand on field 'age' is a Amount instance, which the in-memory matcher compares only by order…`. The spec's comparand door refuses it at these operators.
27+
- Not moved: under `$gt` / `$gte` / `$lt` / `$lte` / `$between` it is still compared through its `valueOf`, and `$icontains` keeps its own text-comparand refusal.
28+
29+
**Not moved.** A scalar, a `Date` and a `{ $field }` reference are compared as before; `$empty` keeps its boolean-flag refusal, with the converter's sentence now built by the same helper as `$null` / `$exists`; a `null`-prototype object of this realm is still an operator map.
30+
31+
The fix for a caller: write the flag as the boolean itself (`{ owner: { $null: true } }`, `{ owner: { $exists: false } }`); compare with a scalar, a `Date` or a `{ $field }` reference; filter a relative date on a server-backed source, or compare a value source with a concrete `Date` or ISO string; and convert a class-instance comparand to its primitive (`moment.toDate()`, `decimal.toNumber()`) before filtering.
32+
33+
**Corrections to earlier notes** (the nested-relation drill note for `@object-ui/core`):
34+
35+
- Its FROM said an ordering operator compared a plain-object comparand with the text `[object Object]`. That holds for an object whose prototype is `Object.prototype`. A `null`-prototype object has no `toString` or `valueOf`, so under `>`, `>=`, `<`, `<=` and `not_contains` the comparison threw `TypeError: Cannot convert object to primitive value` and `find` rejected, before that change.
36+
- Its sentence "`=` matched no row before" leaves out one row: `=` compared by reference, so a row holding the caller's own object, stored through `create` or `update`, which copy shallowly, matched.

‎ui/packages/plugin-dashboard/src/DatasetWidget.tsx‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,9 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden, packag
891891
const [state, setState] = useState<{ status: 'idle' | 'loading' | 'ok' | 'error'; rows: Row[]; fields?: DatasetResultField[]; object?: string; dimensionFields?: Record<string, string>; drillRawRows?: Array<Record<string, unknown>>; drillRanges?: Array<Record<string, DatasetDrillRange>>; totals?: DatasetResultTotals[]; drillScopes?: unknown; error?: string; forbidden?: boolean; signature?: string; refreshing?: boolean }>({ status: 'idle', rows: [] });
892892
// Drill-through (ADR-0021 D2): the clicked bucket's record-list filter + title.
893893
// A bucket on a relationship-path dimension opens the drawer on a `notice`
894-
// while its related ids are read, and keeps one when they cannot be
895-
// (`resolveDatasetDrillFilter`); `filter` is set once there is a list to read.
894+
// while each hop's schema is read, and keeps one when the path cannot be
895+
// drilled (`resolveDatasetDrillFilter`); `filter` is set once there is a list
896+
// to read.
896897
const [drill, setDrill] = useState<{ filter?: Record<string, unknown>; title: string; notice?: DrillDownNotice } | null>(null);
897898
// The click a pending relationship resolution answers: a later click, or the
898899
// drawer closing, makes an earlier answer stale.
@@ -1331,11 +1332,13 @@ export function DatasetWidget({ widget, dataSource, heading, onForbidden, packag
13311332
const drillTitle = title || String(widget?.title ?? '');
13321333
const request = ++drillRequest.current;
13331334
const scopedFilter = scopeDrillFilter(runtimeFilter, scope);
1334-
// A dimension whose field is a `relationship.field` path is filtered on the
1335-
// relationship field `$in` the related ids matching the clicked value, read
1336-
// through this widget's data source first: the data API refuses the dotted
1337-
// path itself. The drawer opens at once on a notice and lists once the
1338-
// ids are in; a path it cannot resolve, or too many ids, keeps a notice.
1335+
// A dimension whose field is a `relationship.field` path drills as one
1336+
// nested-relation condition (`{ account: { owner: VALUE } }`), which the
1337+
// server matches in the database; no related id is read here. Each hop's
1338+
// schema is read through this widget's data source first, to confirm it is
1339+
// a single-valued relationship, so the drawer opens at once on a notice and
1340+
// lists once the filter is built; a path it cannot drill keeps a notice.
1341+
// `too-many` is no longer produced and stays mapped for compatibility.
13391342
if (datasetDrillHasRelationshipPath(drillDims, dimensionFields)) {
13401343
setDrill({ title: drillTitle, notice: 'resolving' });
13411344
resolveDatasetDrillFilter({

‎ui/packages/plugin-dashboard/src/DrillDownDrawer.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ export interface DrillDownDrawerProps {
7474
* none can be read (a dataset drill across a relationship,
7575
* `resolveDatasetDrillFilter` in `@object-ui/core`):
7676
*
77-
* - `'resolving'` — the related ids are still being read;
78-
* - `'too-many'` — more related records match than the drill may list;
77+
* - `'resolving'` — the relationship path is still being checked (one
78+
* schema read per hop; no related id is read);
79+
* - `'too-many'` — kept for compatibility: a relationship drill no longer
80+
* produces it, because it reads no related ids to count;
7981
* - `'unavailable'` — the relationship cannot be resolved from here;
8082
* - `'failed'` — a read on the way failed.
8183
*

‎ui/packages/plugin-report/src/DatasetReportRenderer.tsx‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,15 @@ function drillFilterOrRefusal(
869869

870870
/**
871871
* The drill filter of a bucket whose dimensions cross a relationship
872-
* (`relationship.field` paths in `dimensionFields`), handed to `emit` once the
873-
* related ids are read — `resolveDatasetDrillFilter` in `@object-ui/core`.
874-
* The data API refuses the dotted path itself, so the filter names the
875-
* relationship field `$in` the related ids matching the clicked value.
872+
* (`relationship.field` paths in `dimensionFields`), handed to `emit` once each
873+
* hop's schema is read — `resolveDatasetDrillFilter` in `@object-ui/core`.
874+
* The data API refuses the dotted path itself, so the filter is one
875+
* nested-relation condition (`{ account: { owner: VALUE } }`), which the server
876+
* matches in the database; no related id is read here.
876877
*
877878
* A bucket it cannot resolve (a path past ADR-0071's hop limit, an unknown
878-
* relationship, the empty bucket, more related records than the drill may
879-
* list) or a read that fails emits no drill and logs why: the host builds its
879+
* relationship, the empty bucket) or a read that fails emits no drill and logs
880+
* why (the `too-many` branch below is no longer produced): the host builds its
880881
* own fallback from an absent `objectFilter`, which would drop the scope, so
881882
* there is no drill rather than a wider one — the posture
882883
* {@link drillFilterOrRefusal} takes for a refused filter.

0 commit comments

Comments
 (0)