Skip to content

Commit 3781dec

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-l4gpcv
2 parents 5b52017 + d01f399 commit 3781dec

4 files changed

Lines changed: 405 additions & 1 deletion

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/service-analytics': patch
3+
---
4+
5+
fix(service-analytics)!: the native SQL strategy evaluates a cross-object `where` leaf on an existing parent, so a detail row with no parent is not selected, as on the engine path and `/data`
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. The moved answer is an aggregate over a cross-object filter, which now leaves out the detail rows with no parent, as the engine path and the /data nested-relation filter already did: 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 a reader of an analytics answer served by the native SQL strategy (a cube or dataset query with no bucketed time dimension, on a SQL datasource) that reads a related object's field through a relationship path (`'order.status'`) in any of the three filter positions one compile serves: the query's `where`, a measure's own `filter` (its conditional aggregate) and the dataset's own `filter`:
13+
14+
- FROM: a detail row whose relation field is empty, or names no existing record, was selected by `$ne`, `$nin`, `$notContains`, `$null: true`, `$eq: null`, `$exists: false` and `$empty: true` on the related field, because the `LEFT JOIN` read every related column of such a row as NULL. So the same widget answered a different total once a time bucket sent it to the engine path. TO: such a leaf is evaluated on an existing parent (the last hop's `id = id` is conjoined to it, through every hop of the path: TRUE for an existing parent, UNKNOWN for none, so a `$not` cannot flip it), and outside `$not` no such row is selected by those operators. Under `$not` the native answer is the one it gave before. The native, engine and `/data` answers agree on those operators.
15+
16+
**Not moved.** A parent that exists with no value in the field still satisfies `$ne`, `$nin`, `$notContains` and `$null: true`. A positive operator (`$eq` a value, `$in`, `$gt`, `$contains`, …) selected no such row before either, and its statement is unchanged. A leaf on the base relation field itself (`{ order: { $null: true } }`) reads no join and is unchanged. Two native-path answers still select such a row, unchanged by this release: a positive comparison under `$not` (`{ $not: { 'order.status': 'open' } }`, a shape the engine path refuses; write `$ne` / `$nin` inside the condition instead), and `$nin: []`, which folds to the constant TRUE and selects every row, where the engine path leaves such rows out.
17+
18+
The fix for an author who wants the rows with an empty relation: OR the base relation field in, `{ $or: [{ 'order.status': { $ne: 'open' } }, { order: { $null: true } }] }`. A row naming a record that no longer exists is not brought back by it, on either path.

‎content/docs/ui/dashboards.mdx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,21 @@ the base rows whose relationship points at a record it returned:
532532
condition under `$not` (write `$ne` / `$nin` inside the condition instead), and
533533
a related field compared with another field (`$field`).
534534

535+
On the native SQL path, too, a related-field condition that is not under
536+
`$not` never selects a row with no related record (an empty relationship, or
537+
one naming a record that no longer exists), whether it sits in the query's
538+
filter, a measure's own `filter` or the dataset's own `filter`: `$ne`, `$nin`,
539+
`$notContains`, `$null: true`, `$eq: null`, `$exists: false` and `$empty: true`
540+
included, so the two paths agree on such rows. The same `$or` brings back the
541+
rows with an empty relationship on both paths; a row naming a record that no
542+
longer exists is not brought back by it. A related record that exists with no
543+
value in the field still satisfies `$ne` and `$nin`. Two native-path exceptions
544+
remain: under `$not`, which the engine path refuses, the native path still
545+
selects such a row when the negated condition is a comparison with a value
546+
(`{ $not: { 'order.status': 'open' } }`), so write `$ne` / `$nin` inside the
547+
condition instead; and `$nin: []` (an empty list) selects every row on the
548+
native path, such rows included, where the engine path leaves them out.
549+
535550
A related field in a **dataset's own** `filter`, or in a **measure's** own
536551
`filter`, is still evaluated only on the native SQL path; the engine-aggregate
537552
path refuses it (`400 INVALID_FIELD`) rather than count rows it cannot join.

0 commit comments

Comments
 (0)