Commit f7a60d9
driver-mongodb was the last backend still ANSWERING three filter shapes every
other backend refuses. All three failed the same way — the query ran, reported
nothing, and returned a row set nobody asked for. Measured through
translateFilter on origin/main @ 76d74ec:
{ score: { $between: 5 } } => {"score":{}}
{ $where: 'return true' } => {"$where":"return true"}
{ stage: {} } => {"stage":{}}
All three now refuse with INVALID_FILTER / 400 (ADR-0112), naming the position,
through the existing unsupportedFilterError constructor — no third envelope.
- Malformed $between: the emitter arm wrote both bounds inside
`if (Array.isArray(value) && value.length === 2)` with no else, so a malformed
comparand dropped the range and normalised the field to {}. The twin, down to
the missing else, of the arm #5328 fixed on driver-memory.
- An undeclared $-key in a NODE position: the translator's switch knows three
combinators; every other key took the FIELD path and, carrying no $-prefixed
sub-keys, fell to implicit equality and was written into the outgoing document
verbatim — where MongoDB EXECUTED it. $where is server-side JavaScript. The
emitter's field-level default: arm has named these exact spellings as its P0
reason for refusing them one level down for two releases; the node position
had no such gate. driver-sql / driver-sqlite-wasm compiled a column of that
name (#5348, since refused), driver-memory refused (#5324) — only here was it
evaluated.
- { field: {} }: ruled REFUSE on #5240, gated on the four other backends by
#5327. This driver translated it to { field: {} }, which MongoDB reads as
"deep-equal to the empty document" — not the FALSE the ruling declined to
take, but a DIFFERENT filter that looks like FALSE until a document stores {}.
Each gate sits on the validating walk (classifyFilterKey), beside the existing
$null (#5347) and $icontains (#6520) gates, not in the emitter — the emitter is
skipped wholesale when a boolean identity settles the enclosing node. Measured
before the fix, all three of `{ $or: [ {}, { $where: 'x' } ] }`,
`{ $or: [ {}, { score: { $between: 5 } } ] }` and `{ $or: [ { a: {} }, {} ] }`
translated to {} — match-all. The $between emitter arm keeps a local check as
defense for its own invariant, the dual-gate pattern the $null arm documents.
Wordings are driver-sql's / driver-memory's leading sentences verbatim — one
condition, one wording (#5240) — with no package-name prefix (#3867).
The verdict is unchanged: a field key still classifies as 'clause'. This adds
refusals in front of it rather than reclassifying a surviving shape, so every
filter that translated before translates byte-identically.
Tests: 37 new cases in mongodb-filter-shape-refusal.test.ts, each asserting code
and status alongside the pinned sibling wording, plus a walk-not-emitter block
pinning the three sibling-dependence fixtures. The #5239 pin that recorded
{ field: {} } as "still not ruled on" is rewritten to record the ruling arriving.
Package suite 269 passed / 143 skipped (live-mongod halves are skipIf-gated;
mongodb-memory-server's binary is not downloadable here). check:driver-conformance
OK.
Claude-Session: https://claude.ai/code/session_018oM7XYyQ6AveqQs6eqxDdv
Co-authored-by: Claude <noreply@anthropic.com>
1 parent b78016f commit f7a60d9
5 files changed
Lines changed: 631 additions & 24 deletions
File tree
- .changeset
- packages/drivers/driver-mongodb/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 | + | |
| 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 | + | |
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
284 | 300 | | |
285 | 301 | | |
286 | 302 | | |
| |||
0 commit comments