Commit e6b1bb0
The analytics filter normalizer flattened every comparand into `values:
string[]` and had its consumers GUESS the type back out. An all-strings
encoding has no escape, so author strings collided with the tokens the
encoder wrote for other types: `{code: {$eq: 'null'}}` bound real NULL
(UNKNOWN for every row), `'true'` bound 1 / true, and `'007'` / `'1.50'`
bound 7 / 1.5 until #5528 narrowed that half as an explicit stopgap.
`NormalizedFilterNode`'s leaf `values` is now `unknown[]`. The author's
value travels through the tree untouched and nothing decodes it.
`stringifyForCube`, `recoverNumber`, `coerceFilterValueForSql` and
`coerceFilterValueForObjectQL` are deleted. Conversion survives only
where a boundary demands it:
- `toSqlBindValue` — one-way, and it inspects no string: it converts only
the JS types a driver cannot bind (boolean -> 1/0, Date -> ISO,
object -> JSON).
- the LIKE family, whose comparand `filter.zod.ts` declares a `string`,
so `like-pattern.ts` and `convertFilter` stringify at the emitter — the
same `String(value)` `driver-sql`'s `applyLike` applies, keeping one
`$contains` meaning one thing on both faces.
The ObjectQL engine path now converts nothing at all: the engine compares
against the stored runtime type and receives the author's own value.
Two readings changed as a consequence, both toward fail-closed:
`{$contains: null}` was `LIKE '%%'` (matching every non-NULL row) and is
now `LIKE '%null%'`, which is what driver-sql has always compiled;
`{$gt: null}` was `> ''` (a real comparison against the empty string) and
now binds NULL, so the predicate is UNKNOWN. `timeDimensions[].dateRange`
bounds forward at the `string` type the spec declares them with, instead
of being re-read as epoch-ms numbers by a lenient consumer.
The null-predicate semantics of #5332 / #5525 and the LIKE escaping
contract of #5567 are untouched, both pinned by row-set tests.
#5528's test asset is carried forward whole:
filter-value-canonical-number.test.ts becomes
filter-value-type-fidelity.test.ts, with every case upgraded from "what
does the decoder return" to the end-to-end leaf/SQL-bind/engine-bind
question, plus decoy rows storing the text 'null' and 'true' beside a real
NULL. Reverse-verified: re-inserting the encoder turns those pins red.
Fixes #5526
Claude-Session: https://claude.ai/code/session_01BWS4heBoAitLmzCLhcYdbK
Co-authored-by: Claude <noreply@anthropic.com>
1 parent d4edb5d commit e6b1bb0
9 files changed
Lines changed: 949 additions & 559 deletions
File tree
- .changeset
- packages/services/service-analytics/src
- __tests__
- strategies
| 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 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | | - | |
158 | | - | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
0 commit comments