Commit c637387
* fix(service-analytics): only a canonical numeric spelling is a number, so '007' / '1.50' stay strings (#5528)
An analytics `where` round-trips every comparand through `values: string[]` —
`stringifyForCube` out, `coerceFilterValueForSql` / `coerceFilterValueForObjectQL`
back — and the decoder decided "this is a number" from the string's SHAPE alone
(`/^-?\d+(\.\d+)?$/`), which cannot tell a stringified number from a string the
author wrote. Measured on main, cube `orders` / TEXT column `code`: `'007'` bound
`7`, `'0912'` bound `912`, `'1.50'` bound `1.5` — on BOTH consumers, the raw-SQL
bind and the engine comparand.
The failure was silent and MIS-TARGETED rather than empty: SQLite applies the
text column's affinity to the integer bind, so a widget filtered on order number
`'007'` returned the row storing `'7'`. On Postgres the same query is a
`text = integer` type error; on the engine path the strict comparison matched
nothing (measured: 0 rows). Zero-padded and trailing-zero strings are ordinary
business shapes — order numbers, SKUs, dialling codes, postcodes, prices.
Recovery is now limited to a number's own canonical spelling
(`String(Number(s)) === s`): a comparand that really was a number arrives as
`String(n)` by construction and still round-trips (`7` → `'7'` → `7`), while a
string `Number()` would rewrite cannot have come from a number and stays the
author's string. The shape regex still runs FIRST, so the change can only remove
recoveries — `'1e3'`, `'1e+21'`, `'+7'`, `' 7'`, `'0x10'`, `'Infinity'`, `'NaN'`
were strings before and are strings after. This is the direction ADR-0053 D-A2
already set for this function: last-resort textual recovery behind the
driver-backed `coerceTemporalFilterValue` hook.
Stopgap by design, and named as one in the TSDoc and the tests: `values: string[]`
still has no escape, so the author strings `'null'` / `'true'` / `'false'` still
collide with the tokens the encoder writes for the real values. That is #5526's
root cause (tagged values, or an `unknown[]` internal representation), pinned here
as UNCHANGED so it is not mistaken for fixed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWS4heBoAitLmzCLhcYdbK
* style(service-analytics): fix two stray indents in the #5528 test file
Left over from dropping three `eslint-disable-next-line
@typescript-eslint/no-explicit-any` comments: that rule is not defined in this
repo's eslint config, so the disables themselves were errors ("Definition for
rule ... was not found"). The sibling `filter-operator-coverage.test.ts` uses the
same `let db: any` harness with no disable comment.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWS4heBoAitLmzCLhcYdbK
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 52caf23 commit c637387
3 files changed
Lines changed: 512 additions & 6 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 | + | |
0 commit comments