Skip to content

Commit b559fc5

Browse files
committed
docs(changeset): correct the nested-relation drill note in place instead of a later erratum
Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0c86f9c commit b559fc5

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

‎.changeset/34990-nested-relation-filter-node.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Metadata-protocol: none
1111

1212
**BREAKING** for a host that filters a `ValueDataSource` (the in-memory `provider: 'value'` source) with a comparison whose comparand is a plain object (prototype `Object.prototype` or `null`) with no `$` key, such as `['account', '!=', { owner: 'u1' }]`, under `!=`, `not_contains` or an ordering operator (`>`, `>=`, `<`, `<=`).
1313

14-
- FROM: `!=` and `not_contains` served every row, and an ordering operator compared each value with the text `[object Object]` and served the string values that happened to sort past it.
15-
- TO: the condition is refused by name. It excludes every row and logs the sentence the object form `{ account: { owner: 'u1' } }` already logs. `=` matched no row before and matches none now; it only gains the log line.
14+
- FROM: `!=` and `not_contains` served every row, and an ordering operator compared each value with the text `[object Object]` and served the string values that happened to sort past it. That holds for an object whose prototype is `Object.prototype`. A `null`-prototype object has no `toString` or `valueOf`, so under `not_contains` and the ordering operators the comparison threw `TypeError: Cannot convert object to primitive value` and `find` rejected.
15+
- TO: the condition is refused by name. It excludes every row and logs the sentence the object form `{ account: { owner: 'u1' } }` already logs. `=` compared by reference, so it matched no row unless a row held the caller's own object (stored through `create` or `update`, which copy shallowly), and that row matched; it matches none now and gains the log line.
1616
- The spec's comparand door already refuses an object comparand under these operators, so the rows served before were a wrong answer. Spell a relation condition only against a server-backed source, whose server joins it; a value source holds flat rows, so filter there on the row's own fields.
1717

1818
`convertFiltersToAST` now lowers the nested-relation form the spec declares on `FilterCondition` (`{ account: { owner: 'u1' } }`, a plain object with no `$` key beneath a field) to one equality node, `['account', '=', { owner: 'u1' }]`, which the spec's `parseFilterAST` reads back as the same nested condition. It used to refuse that shape as an unknown operator. The condition travels as written, deeper relations included; whether the field is a relationship is judged by the server, which answers `INVALID_FILTER` / 400 for such a condition under a field that stores a scalar or a structured-JSON value, and, under a relationship, for a condition key the related object does not declare, a dotted key, or a relation nested past the hop limit. A map that mixes `$` operators with plain keys is still refused.

‎.changeset/35735-filter-flag-and-comparand-edges.md‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,3 @@ Metadata-protocol: none
2929
**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.
3030

3131
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.

0 commit comments

Comments
 (0)