Repository navigation
Commit 2095040
fix(driver-memory): count a boolean aggregand as 1/0 in avg and sum (#11153)
* fix(driver-memory): count a boolean aggregand as 1/0 in avg and sum
`avg` over a boolean column returned `null` on driver-memory while SQLite
answered the arithmetically correct rate over the same rows, and objectql's
in-memory fallback answered that same rate — driver-memory was the lone
outlier of the three. Both of this package's faces carried the divergence
independently: the data face filtered aggregands with `typeof v === 'number'`,
and the analytics face emitted a bare mingo `$avg`, which ignores non-numeric
values as MongoDB's does.
`sum` shares the data face's arm and had the same defect one function over
(`SUM(bool)` is "how many true" on every SQL face), so it is aligned with
`avg` rather than left behind.
The coercion is boolean-only: null, missing and non-numeric strings reach the
accumulators unchanged and stay excluded, rather than being folded to 0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfyXxZ2WPjcjhuXpiQQc3y
* test(driver-memory): record the reverse verification, and add the changeset
The ablation was run after the fix was committed so it had a restore point:
both coercions reverted to origin/main's expressions, the mutation confirmed
on disk by marker counts in both directions, then restored by a trap.
Measured 11 failed / 4 passed against a predicted 10 — the direction held
exactly (every failure on a value, none on a throw) and the predicted count
was off by one. Both numbers are recorded rather than the prediction being
quietly rewritten to match.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfyXxZ2WPjcjhuXpiQQc3y
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8cc8401 commit 2095040
4 files changed
Lines changed: 416 additions & 3 deletions
File tree
- .changeset
- packages/drivers/driver-memory/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
483 | 529 | | |
484 | 530 | | |
485 | 531 | | |
| |||
1192 | 1238 | | |
1193 | 1239 | | |
1194 | 1240 | | |
1195 | | - | |
| 1241 | + | |
1196 | 1242 | | |
1197 | | - | |
| 1243 | + | |
1198 | 1244 | | |
1199 | 1245 | | |
1200 | 1246 | | |
| |||
0 commit comments