Commit 3264516
* fix(driver-sql,service-analytics)!: refuse the two comparand shapes that compiled to a silent nonsense predicate (#5234)
An `$in`/`$nin` list member that cannot be bound, and a LIKE-family comparand
that `String()` cannot render, both compiled to valid SQL that answered with a
predicate the caller never wrote:
- `{status: {$in: ['a', {foo: 1}]}}` answered as if the second member had
never been written; `{status: {$nin: [{foo: 1}]}}` excluded NOTHING, so the
exclusion the caller wrote silently did not happen.
- `{name: {$contains: {}}}` bound `LIKE '%[object Object]%'` and MATCHED a row
whose text really was `[object Object]`; `$notContains` excluded it.
#5041 (PR #5223) recorded both as "Deliberately NOT extended" on the grounds
that they were fail-closed. Measured, neither premise held: the `$nin` /
`$notContains` direction is wider, not narrower, and the answers were wrong
rather than empty.
The guard lands at each package's own chokepoint rather than at the three
`String()` emitters, so one `$contains` still means one thing on every face:
`assertCompilableComparand` in driver-sql, `fieldLeaves` for the analytics
`where` door (the only leaf producer, so it covers all three consumers of the
tree), and `compileOperator` for the read-scope lowering. The fence is an
allow-list, copied from driver-turso's RemoteTransport, which has refused these
same two shapes since cloud#1004 / #1058 — local and remote SQLite answered the
same query differently until now.
Primitives are deliberately untouched: `{$contains: 5}` and `{$contains: null}`
agree across every backend today and #5526 pinned the latter. Arrays are refused
because they already forked inside service-analytics (`%al,be%` at the read
scope, `%al%` at the `where` door).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyvqvKMG6asi9aXjKE6xtx
* test(driver-sql): 跟进 #6210 的 DriverQuery 收窄,并把反向验证计数重测到 d367f03
- `find()` 调用去掉 `object` 键:#6210 把驱动查询参数收窄为 `DriverQuery`,
对象名只由第一个实参给出。没有用 `as any` 绕过——拒收类测试一旦用越契约的
输入构造查询,就不再是在验证调用方真能发出的形状。
- 反向验证计数重测:LIKE 臂停用 → 8 failed / 40 passed;成员臂停用 →
4 failed / 44 passed(此前记的 32 / 36 是首写时对 40 个测试测的)。失败数
两次都不变,是承重的那一半;通过数随邻测增删而漂移,已在注释里说明。
- 补记 analytics 侧同法实测:两个门回退到 main 版本 → 17 failed / 41 passed,
而 `like-metacharacter-escape.test.ts` 在该回退下保持绿——它锁的是两包谓词
之间的一致,拒收文件锁的是门确实调用了谓词,两者都需要。
Refs #5234
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyvqvKMG6asi9aXjKE6xtx
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 6517448 commit 3264516
11 files changed
Lines changed: 1201 additions & 22 deletions
File tree
- .changeset
- packages
- drivers/driver-sql/src
- 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 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
Lines changed: 35 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
312 | 332 | | |
313 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
314 | 343 | | |
315 | 344 | | |
316 | 345 | | |
0 commit comments