Commit fa4d3ca
committed
fix(analytics): compare boolean filters/group-by against real boolean, not stringified '1'
The analytics filter normalizer stringified boolean `true` → `'1'`, which the
ObjectQL strategy then coerced back to the number `1` before passing it into
`engine.aggregate`. Stored boolean fields hold a real `true`/`false`, so
`1 !== true` never matched: boolean metric widgets always returned 0 and
boolean group-by dimensions failed to bucket.
`'1'`/`'0'` was indistinguishable from a numeric 1/0, so the boolean identity
could not be recovered. Fix the roundtrip:
- `stringifyForCube` now serializes booleans as the tokens `'true'`/`'false'`,
preserving the boolean identity through the `string[]` pipeline form.
- New `coerceFilterValueForObjectQL` recovers a real `true`/`false` for the
ObjectQL engine (compares against the stored runtime type); the SQL path keeps
recovering `1`/`0` since better-sqlite3 cannot bind a JS boolean. Shared
numeric recovery extracted into `recoverNumber`.
- ObjectQLStrategy.convertFilter uses the new ObjectQL coercer.
Adds a regression test whose mock engine filters/buckets in-memory rows by
STRICT `===`: a `{ is_critical: true }` filter yields a non-zero count, `false`
matches its rows, and a boolean group-by produces both true/false buckets.1 parent d616e1d commit fa4d3ca
3 files changed
Lines changed: 42 additions & 17 deletions
File tree
- packages/services/service-analytics/src
- __tests__
- strategies
Binary file not shown.
Lines changed: 39 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | | - | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| |||
118 | 128 | | |
119 | 129 | | |
120 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
121 | 140 | | |
122 | 141 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
126 | 146 | | |
127 | 147 | | |
128 | 148 | | |
129 | 149 | | |
130 | 150 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
140 | 165 | | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
236 | | - | |
| 235 | + | |
| 236 | + | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| |||
0 commit comments